mod_rewrite can't "see" files

Discuss practical ways rearrange URLs using mod_rewrite.

mod_rewrite can't "see" files

Postby laserlemon » Wed Apr 08, 2009 7:27 am

I have a simple maintenance file rewrite rule. The purpose is to check for the existence of a maintenance file and if it exists, to serve it up. This way, whenever I need to do site maintenance, I can simply create that file. Here are the rules:

Code: Select all
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /maintenance.html [L]


The problem I'm having is that it doesn't seem as though mod_rewrite can see that the maintenance file exists. Here is a line from the rewrite logs:

Code: Select all
RewriteCond: input='/home/laserlemon/maintenance.html' pattern='-f' => not-matched


That file certainly does exist and has 775 permissions. Does anybody have any insight into why mod_rewrite might have trouble seeing that this file exists?
laserlemon
 
Posts: 2
Joined: Wed Apr 08, 2009 6:59 am

Postby richardk » Wed Apr 08, 2009 1:04 pm

What happens if you replace %{DOCUMENT_ROOT} with your document root?
What happens if you try a different file name?
What happens if you remove the second RewriteCond?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby laserlemon » Tue Apr 21, 2009 6:15 am

Replacing %{DOCUMENT_ROOT} with my actual document root doesn't change anything and I confirmed that mod_rewrite is looking for the file in the correct location even when using %{DOCUMENT_ROOT}.

Same issue with a different filename.

Also, nothing changes if I remove the the second RewriteCond. The logs show that it stops evaluating the conditions once the first fails (which it always does).

Unfortunately, this is an issue that's occurring on my production server and I can't seem to reproduce it elsewhere so there's only so much potentially destructive experimentation I'm willing to do.
laserlemon
 
Posts: 2
Joined: Wed Apr 08, 2009 6:59 am

Postby richardk » Tue Apr 21, 2009 7:56 am

I can't think of any reason why it doesn't work.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 23 guests

cron