Test if htaccess is working
Created: Last updated:
When you set up a new website with an Apache (httpd) Web Server you may use the .htaccess configuration file with some site specific configuration directives. For some unexpected reason every rule fails and you wonder if the htaccess configuration file is even enabled or read. Why is it not working?
When all rules fail first thing we should do is verify if the htaccess file is accessed and the configuration loaded. There is obviously no need to look over the rules when it's not touched.
Force an error
The simple solution to verify and check if the .htacess configuration file is even touched and parsed is forcing an error. More precisely a 500 Internal Server Error.
Force an Internal Server Error
In order to do that you simple add something to the first line of the config file that doesn't make any sense. This could be a single letter or number, a word, basically anything that is not a directive.
If you get the 500 Internal Server Error you know that the file has been read because that line triggered the error.
If you don't get an error your server setup is wrong because your .htaccess has not even been touched. Check out the other documents in my knowledge base for answers to that question.
Further help
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.