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 "mysite.com" be redirected to "mysite.com/maintenance.php";
  • 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


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]

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} ! example.com
RewriteRule /.* /maintenance.html [L]

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.