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

My site is in maintenance(construction). How to redirect visitors to a "site in maintenance" single page?

I heard something about app_offline.htm for ASP.NET.

Is there something similar for PHP?

  • I want that every page from "" be redirected to "";
  • I don't want to do the minimum modification in the existing site pages, ideally no one.

Apache version 2.2.15
PHP version 5.2.13

share|improve this question
up vote 4 down vote accepted

In Apache with mod_rewrite create a .htaccess file in the DocumentRoot folder containing:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} !/images/maintenance.png$
RewriteCond %{REQUEST_URI} !/maintenance.php$

# here filter the developer's IP/
#RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888

RewriteRule $ /maintenance.php [R=302,L]
share|improve this answer

In apache with mod_rewrite you can do it easily, just make the first rule something like

RewriteRule /.* /maintenance.html [L]

If you want to be able to test the site while everybody else sees the maintenance page, you can also add a condition, excluding some IP addresses, e.g.

RewriteCond %{REMOTE_HOST} !
RewriteRule /.* /maintenance.html [L]
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.