Server Fault is a question and answer site for system and network administrators. 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've got a site that's the back-end of a system that we have designed. normally, we go to different venues and connect the the back-end system over the internet and carry on.

We now have to go to a venue that is literally in a field and has no internet access whatsoever. I have got the system running on a local machine, no problem, but I want to make the main site on the internet unavailable for users, but give them a message telling them what has happened.

At the moment I've got a .htaccess in the root:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)$ [R,L]

Which half works, but browsers don't like it:

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

To recap, I want any URL entered:

to end up at

Any ideas?

thanks, Kevin

share|improve this question
up vote 3 down vote accepted

The short version is that your rewrite rule needed an exclude parameter for offline.php. Otherwise it was trying to redirect all pages in that domain including offline.php - thus the infinite loop Firefox was warning you of.

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/offline\.php$
RewriteRule ^(.*)$ [L,NC,R=301]

For more information, check out the solution described at ".htaccess and mod_rewrite (redirects) Explained".

Redirecting all your pages to one:

This special rewrite is useful when a you need to close a site (permanently or for maintenance) and send the traffic from all the pages to a special page that explains the current situation. This example excludes stylesheets, jpg and gif images from the redirect, so you can still use our "look and feel" on the special pages. See my Mod_rewite Redirects All Site Pages To One post for some more on this one.

share|improve this answer
Good answer. It basically changes my viewpoint from "Change everything" to "Change everything that isn't the final destination that I want". I changed it slightly to use code 302 as The site will be going back up once we've finished in the field. Cheers. – Kevin Jones Aug 7 '10 at 17:27
To do the rewrite a few miliseconds faster, you can write ------- RewriteRule ^ [L,NC,R=301] ------- ^ means start of a string. This will always be true and will not check (.*) the regex condition until the end – DrDol Aug 14 '10 at 23:03
An other neaty feature is to get only acces from a certain ip or subnet by adding ------------ RewriteCond %{REMOTE_ADDR} !^123\.255\.123\.255$ --------- before or after the first RewriteCond. – DrDol Aug 14 '10 at 23:09

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.