Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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

Your Answer

 
discard

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.