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 have website content like

Now I want to put a maintenance page so people who will visit to or will able to see maintenance page however visitors will go to or will not redirect to maintenance page.

I already tried these:

This is redirecting both root and subfolder to maintenance page.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

This is not doing anything

RewriteEngine on
RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ [L,R=301]
share|improve this question
Did you want to redirect to the maintenance page or the second site? – Shane Madden May 12 '12 at 3:15
No Shene, I want redirect root index.php to maintenance page but not sub directories – Sandy Fark May 12 '12 at 6:09

According to the HTTP Spec the correct response to return would be a 503 Service Unavailable, and you should do this from / rather than redirecting.

You could use Bittrance's solution, it should work, although you might want to separate out the rules since you'll probably want to redirect index.php to / in the long run.

I would certainly discourage using a 301 redirect to point to a maintenance page, that would indicate that it is a permanent redirect rather than maintenance, if you must do a redirect I'd recommend using a 302.

To summarise, I think the best solution would be to 301 redirect index.php to / since you'll want that anyway, and whilst you're performing maintenance, / should return a 503 (and you can still have a nice maintenance page there), it's just your PHP's job to serve it not htaccess.

share|improve this answer

Not sure I understand your question. Is there some reason you can't do:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(|/|/index.php)$ [R=301,L]

... or some similar limited rerwriterule?

share|improve this answer

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.