Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to exclude mod_rewrite for a certain directory.

I want the folder "phd_application" not to be rewritten, that is, when a url points to 

it goes to that folder.

It works when uploaded on the web server but doesn't work locally, and I don't understand why. I have the same .htaccess file locally and remote. What am I missing?

I have the following .htaccess

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^(phd_application/) - [L]
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]

The content of the directory where the .htaccess reside

-rwxr-xr-x   1            183 Dec 19 12:43 .htaccess
drwxr-xr-x  13             18 Dec 13 15:44 app
lrwxrwxrwx   1             15 Dec 13 14:48 cake -> ../CakePHP/cake
-rwxr-xr-x   1           1850 Dec 13 15:14 index.php
drwxr-xr-x   3              8 Dec 19 12:46 phd_application
lrwxrwxrwx   1             18 Dec 13 14:49 plugins -> ../CakePHP/plugins
lrwxrwxrwx   1             18 Dec 13 14:50 vendors -> ../CakePHP/vendors
share|improve this question
up vote 1 down vote accepted

What does the log say ? Enable the rewritelog on the local machine and check what happens.

FYI excluding one location from an otherwise global rewrite is much better done with a RewriteCond.


   RewriteRule    ^$ app/webroot/    [L]
   RewriteCond    ${REQUEST_URI} !^phd_application/
   RewriteRule    (.*) app/webroot/$1 [L]
share|improve this answer
Could you give an example of how it should be done? – kaklon Dec 19 '11 at 13:16
Thank you for the example, but don't change the outcome. The log shows the condition isn't taken in account and redirected to app/webroot/phd_application, that the third rule is applied – kaklon Dec 19 '11 at 13:44
Argh, stupid me the directory name was not the same locally, I am trully sorry. I looked over and over but didn't see that – kaklon Dec 19 '11 at 13:47

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.