Htaccess code for maintenance page redirect

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} !^127.0.0.1$
    #RewriteCond %{REMOTE_ADDR} !^111.111.111.111$
    RewriteCond %{REQUEST_URI} !/maintenance/maintenance\\.htm$ [NC]
    RewriteCond %{REQUEST_URI} !\\.(jpg|jpeg|png|gif|css|ico)$ [NC]
    RewriteRule ^(.*)$ /maintenance/maintenance.htm [R=302,L]

FF,

Aw, if you are redirecting to the maintenance folder, chances are that you’re changing the folder level of the request which is upsetting the relative links which are looking relative to the requested URI. I’d tell others to read the tutorial but, since I brought you onboard, either use the <base> tag (with the actual URI) OR links relative to the original request (not the maintenance folder) OR use absolute internal links. It would be easiest for your single file to use the <base> tag but the absolute internal links are awfully handy, too.

Regards,

DK

All image files from anywhere on the website are redirected to the maintenance.htm page. It’s not just a relative link issue on that particular page.

For example, if I try to visit [I]http://mydomain.com/myimage.jpg[/I] or [I]http://mydomain.com/maintenance/construction.jpg[/I], the images get redirected to [I]http://mydomain.com/maintenance/maintenance.htm[/I]

FF,

    #RewriteCond %{REMOTE_ADDR} !^127.0.0.1$
    #RewriteCond %{REMOTE_ADDR} !^111.111.111.111$
    RewriteCond %{REQUEST_URI} ![SIZE=4][COLOR="#FF0000"]/[/COLOR][/SIZE]maintenance/maintenance\\.htm$ [NC]
    RewriteCond %{REQUEST_URI} !\\.(jpg|jpeg|png|gif|css|ico)$ [NC]
    RewriteRule ^(.*)$ /maintenance/maintenance.htm [R=302,L]

Your code will NOT redirect .jpg, .jpeg,.png, .gif, .css or .ico as specified by your second (active) RewriteCond. Therefore, there must be conflicting code elsewhere in your .htaccess so I have to request that you either post it here or PM me if you need to keep it private.

Whoops, remove the leading / in your first (active) RewriteCond as that requires Apache 1.x. If that doesn’t resolve your issue, then Go Back one paragraph.

Regards,

DK