homepage Welcome to WebmasterWorld Guest from 23.23.57.144
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Search Engine Friendly Temporary Maintenance Page
Allow sub domains and some folders
abushahin

5+ Year Member



 
Msg#: 4459023 posted 2:21 pm on May 29, 2012 (gmt 0)

Hello,
Just wondered if its possible to take the site down for maintenance but still allow sub domains and some folders?

Im found something on the www need help amending


RewriteEngine on

RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000

RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]

RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]

RewriteRule .* /maintenance.html [R=302,L]


ANy help mush appreciated!

 

motorhaven

10+ Year Member



 
Msg#: 4459023 posted 4:21 pm on May 29, 2012 (gmt 0)

Even though Google and other crawlers should recognize the 302 as a temporary relocation I like to avoid sending any page redirection headers.

I send out a "503 Service Unavailable" code instead, which indicates the server is down or undergoing maintenance. Instead of redirecting it to a HTML page I recommend you yend it to a php script which gives the maintenance message:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
RewriteCond %{REQUEST_URI} !/maintenance.php$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.php [L]

Then the maintenance.php script:

<?
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Retry-After: 600'); // Retry after 10 minutes
echo 'Your maintenance message here.";
?>

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4459023 posted 9:11 pm on May 29, 2012 (gmt 0)

The 503 status is the correct one to use.

Downtime of only a few hours is no worry whatsoever.
Google will be back in there in short order soon after the stated expiry time.

abushahin

5+ Year Member



 
Msg#: 4459023 posted 10:41 pm on May 30, 2012 (gmt 0)

Thanks for the correct error code. Is there anyway to allow some folders though using htaccess whilst redirecting all root visiters?

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4459023 posted 10:54 pm on May 30, 2012 (gmt 0)

Be clear, this is NOT a redirect. Redirects return a 30x status code.

This is a method of returning an alternative status code and a human-readable message for some vistors.

Use a series of RewriteCond conditions to select which vistors and/or which user agents see the message and which do not and/or which paths and files are accessible and which are not.

motorhaven

10+ Year Member



 
Msg#: 4459023 posted 11:07 pm on May 30, 2012 (gmt 0)

Noticed a mistake in my code. The echo should end with a single ' quote, not a double " quote.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved