I have website content like



Now I want to put a maintenance page so people who will visit to mysite.com or mysite.com/index.php will able to see maintenance page however visitors will go to mysite.com/apps or mysite.com/apps/index.php 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 ^(.*)$ http://mysite.com/maintenance.html/$1 [R=301,L]

This is not doing anything

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

2 Answers 2


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.


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)$ http://mysite.com/maintenance.html/ [R=301,L]

... or some similar limited rerwriterule?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.