I'm trying to use .htaccess file in VS Code for the 401 and 404 errors, but when I try it out it doesn't work. Here is my code:
ErrorDocument 404 /error404.html
ErrorDocument 401 /error401.html
I was expecting that when I entered an invalid address it would display the error page, but instead it displays the standard error page the cannot GET the page I've searched for answers on Stackoverflow, Codecademy forums, and on developer.mozilla.org. I also tried retyping the code, and using a debugger. The only remote problem I can think of is that I don't have an Apache web server. My programming language is html.
.htaccess
is a file for an apache server. It seems like you just have a directory with your project and open it in e.g. chrome with C:/users/gabe/desktop/myProject
. .htaccess
can't change anything about the fact that your browser tries to open a file that it can't find. The .htaccess
isn't something your browser has access to (when you use it correctly on a server). That wouldn't make sense and would actually be a major security flaw because you would publish information about your server and its structure. Try installing an apache server. That will do the trick