Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Windows server, running Apache. In my Apache conf, I have AllowOverride None for the root of a site and then I have a subdirectory set to AllowOverride All:

<Directory />
AllowOverride None
</Directory>
<Directory "/safe/">
AllowOverride All
</Directory>

However, when I try to set up a rewrite rule in the subdirectory's htaccess file, nothing happens, I just get a 404 page not found error. Example:

RewriteEngine On
RewriteRule (.*) /blah?test=$1 [R=302,NC,NE,L]

Rwewriting URLs are working fine from the root via the Apache conf. I don't understand why the rule is ignored. I don't want to do the URL re-writing within the conf because for this case I may need to be changing the redirects constantly and don't want to reload the server every time a change is made. I also don't want to affect server performance by enabling htaccess files site-wide, just in the subdirectory I need it.

share|improve this question

migrated from stackoverflow.com May 2 '10 at 15:00

This question came from our site for professional and enthusiast programmers.

    
Turn on the RewriteLog (httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog). This should at least give you a hint what mod_rewrite is trying to do. –  joschi May 2 '10 at 15:24
add comment

1 Answer

Beware of Directory & Location tags in Apache configuration, they have really differents meaning. Directory works on filesystem & location on URIs.

If you're talking about an URL like this: http://example.com/safe/index.html you should do like this:

<Location /safe>
    AllowOverride All
</Location>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.