Verify .htaccess is read
Created: Last updated:
You set up a new website with your Apache (httpd) Web Server and add a default .htaccess configuration file to its web root folder with some site specific configuration directives. For some unknown and unexpected reason the rules fail, though. In other words the Apache htaccess configuration rules are not working.
First thing you should do in this case is check if your .htaccess file is even executed, i.e. accessed and load. There is obviously no need to look over the rules if it is not touched, right?
If you need more information about what the .htaccess is then see below What is .htaccess again?
Force an error
The simple solution to verify if the .htacess configuration file is even touched and parsed is forcing an 500 Internal Server Error.
Force an Internal Server Error
So, how do you force such a 500 Internal Server Error from a configuration file? Simple, add something to the first line of the .htaccess that doesn't make sense. Like just a single letter or number, a word, basically anything that is not a directive or complete directive in any form.
If you get the 500 Internal Server Error you will know that the file is accessed or touched and read; that first (garbage) line you added triggers the error.
If you don't get the error than your server setup is wrong, i.e. your .htaccess is either ignored or not found. Check out the other documents in my knowledge base for answers to that question.
What is .htaccess again?
If you are not sure what the .htaccess file is, here's a quick info straight from the Apache Configuration Files documentation.
Apache allows for decentralized management of configuration via special files placed inside the web tree. The special files are usually called .htaccess, but any name can be specified in the AccessFileName directive. Directives placed in .htaccess files apply to the directory where you place the file, and all sub-directories. The .htaccess files follow the same syntax as the main configuration files. Since .htaccess files are read on every request, changes made in these files take immediate effect.
For more information check out the Apache tutorial or the link above.