I am trying to debug some .htaccess problems on Apache but I am new to mod_rewrite.c. I would like to know whether I need to restart Apache in XAMPP whenever I make modifications to the .htaccess files, or whether these are parsed and applied whenever a web page is served independently of whether Apache is restarted.
-
1A restart is needed when editing the central configuration but not .htaccess files. Those are parsed on the fly. Not putting it as an answer because I don't readily know an official source for confirmation – Pekka Sep 06 '15 at 22:56
-
Thank you for your comment. I am trying to get mod_rewrite to work. Do I have to modify the `
` section of the *central configuration file* `C:\xampp\apache\conf\httpd.conf` and restart, or is it enough that ` ` is looking OK. I am having [this problem](http://stackoverflow.com/questions/32427815/xampp-htaccess-mod-rewrite-not-working) at the moment. Do you think you can help me? Thanks. – John Sonderson Sep 06 '15 at 22:59
1 Answers
A restart is not required for changes to .htaccess. Something else is wrong.
Make sure your .htaccess includes the statement
RewriteEngine on
which is required even if it's also present in httpd.conf. Also check that .htaccess is readable by the httpd process.
Check the error_log - it will tell you of any errors in .htaccess if it's being used.
Putting an intentional syntax error in .htaccess is a good check to make sure the file is being used -- you should get a 500 error on any page in the same directory.
Lastly, you can enable a rewrite log using commands like the following in your httpd.conf:
RewriteLog "logs/rewritelog"
RewriteLogLevel 7
The log file thus generated will give you the gory detail of which rewrite rules matched and how they were handled.
Do you have to restart apache to make re-write rules in the .htaccess take effect?
-
Thank you for your answer. Not only does it answer my question but it also provides invaluable insight on how to debug a .htaccess file. Thanks. – John Sonderson Sep 07 '15 at 11:19