I installed Apache on my computer and testing my website locally. I have AllowOverride All and mod_rewrite enabled. I am not sure if my .htaccess files are working properly though.
The following code in .htaccess works on localhost and hosting server (public):
Options All -Indexes
But the following code doesn’t work on localhost although it works on the hosting server:
ErrorDocument 404 /404.php
When I try a non-existent page I get this error on localhost whereas I should be redirected to the custom 404.php page like it does on the hosting server:
Not Found
The requested URL … was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Any ideas what could be wrong with my configuration?
How have you set up your localhost environment? What do your URLs look like? Unless you have set things up specifically for this, your local root folder won’t be found at /.
It is really not a big problem since the same .htaccess file works on my hosting server. But I am trying to figure out why it doesn’t work on localhost.
OK, that’s your problem. The link to /404.php is pointing to your root folder, which is not /mysite/. You can set up your computer so that your test site is at http://mysite/, and then it will work. Here is a tutorial for doing it on a Mac: