Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

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 set up a maintenance page that I could enable through an htaccess file. The html file is located in a folder called "maintenance".

The html file has some images in it. However, visitors to the page see no images, even though I added a RewriteCond line to (theoretically) allow them.

If I try to visit the URL of an image file in the browser directly, it redirects to the maintenance.htm page. I do not want image files to be redirected.

Am I missing something?

#RewriteCond %{REMOTE_ADDR} !^$
#RewriteCond %{REMOTE_ADDR} !^$
RewriteCond %{REQUEST_URI} !/maintenance/maintenance\.htm$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|png|gif|css|ico)$ [NC]
RewriteRule ^(.*)$ /maintenance/maintenance.htm [R=302,L]
share|improve this question

I haven't tested but here is some suggestions for you to try :

  1. Put an other .htaccess in the /maintenance/ folder with a RewriteEngine Off to disable the redirection of images once in this folder.

  2. Make a sub-domain for your maintenance site and redirect everything to this sub-domain with this temporary redirection in your .htaccess located in your main domain : Redirect 302 / http://www.maintenance.mydomain.com/ it'll be more logical as a maintenance site is a website inside of an other, and sub-domains are meat to be used for creating different sites inside an other..

Hope it'll work ! :)

share|improve this answer
Option 1 works. :) However, why doesn't the RewriteCond for images work to begin with? – Force Flow Dec 7 '12 at 14:33
Good ! ;) And ohhh after some research I guess I've found the problem, you need to add an "all characters dot" to say that there is stuff before the actual extension... Something like that : RewriteCond %{REQUEST_URI} !.*\.(jpg|jpeg|png|gif|css|ico)$ [NC] – WiMantis Dec 7 '12 at 20:24

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.