Do you have to restart apache to make re-write rules in the .htaccess take effect?

Jesse Hattabaugh picture Jesse Hattabaugh · Sep 27, 2008 · Viewed 81.6k times · Source

I have pushed my .htaccess files to the production severs, but they don't work. Would a restart be the next step, or should I check something else.

Answer

TomG picture TomG · Sep 27, 2008

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.