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

Basically I want to redirect all requests to my domain to a specific page. For example, redirect all requests to page X, unless you are already on page X, in which case you should just load it. But my solutions just create an infinite loop :/

I tried...

RewriteCond %{REQUEST_URI} !=/underconstruction.html
RewriteRule ^(.*)$$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !^/underconstruction.html
RewriteRule ^(.*)$$1 [L,R=301]
share|improve this question
up vote 1 down vote accepted

From what you described, you want a rewrite rule more like:

RewriteRule ^(.*)$ $LINK [L,R=301]

In other words, lose the $1. That's attaching the original URL to the new URL, which results in an infinite loop.

(I didn't verify the conditionals, but one of those should work, I think)

share|improve this answer

The problem with the examples above is that the RewriteRule lines do not redirect to to underconstruction.html, they redirect roughly to the same URL again (since $1 matches the (.*)).

This example will 301 redirect all URLs to "/underconstruction.html":

RewriteEngine On
RewriteCond %{REQUEST_URI} !=/underconstruction.html
RewriteRule ^ /underconstruction.html [R=301]

(which translates as "If URI is not /underconstruction.html, redirect to /underconstruction.html")

share|improve this answer

How about

<VirtualHost *:80>
   RedirectMatch !^/underconstruction.html http://yourdomain/underconstruction.html
share|improve this answer

Your Answer


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