phpapachehttp-redirectmaintenance-mode

Site in maintenance. How to redirect visitors?


My PHP site in maintenance. 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?

Apache version 2.2.15 under Linux
PHP version 5.2.13


Solution

  • As my Apache in under Linux I do the following:

    Created ".htaccess" file under the site root with the folowing content:

    Options +FollowSymlinks
    RewriteEngine on
    
    RewriteCond %{REQUEST_URI} !/images/mainetnance.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]
    

    Is to remark that I added to filter the .png files, cause I use an image (/images/mainetnance.png) for the maintenance.php, and this image should remain visible, because of global redirect.