Website Under maintenance - Only Web Admin Allow to Access

Discussion in 'Apache' started by coder77, Nov 1, 2012.

  1. #1
    As usual, add RewriteEngine on on top and add below code. Create .html maintenance page and upload to server.
    Add your own IP.


    RewriteBase /
    RewriteCond %{REMOTE_ADDR} !^111\.11\.11\.111
    RewriteCond %{REQUEST_URI} !^/maintenance\.htm$
    RewriteRule ^(.*)$ http://www.yourname.com/maintenance.htm [R=307,L]

    So in your .htaccess file it looks like this:

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REMOTE_ADDR} !^111\.11\.11\.111
    RewriteCond %{REQUEST_URI} !^/maintenance\.htm$
    RewriteRule ^(.*)$ http://www.digitalpoint.com/maintenance.htm [R=307,L]


    Note: do not use RewriteEngine on
    more than one line.
     
    coder77, Nov 1, 2012 IP