Link to home
Start Free TrialLog in
Avatar of linuxraja
linuxrajaFlag for India

asked on

Apache Redirection

   What is the best redirection to add for Google rating during the maintanance time.Currently we are adding the following lines during maintanance.

    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} !^192\.168\.
    RewriteRule /splash/index.html / [R=301,L]

    Google is threatening to remove some sites from their ranking completely due to this.
Avatar of caterham_www
caterham_www
Flag of Germany image

If you're doing some maintenance and your site is not available, HTTP 503 Service Unavailable should be the more appropriate status code.

If you're on apache 2.2, you could use
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^192\.168\.
# only /splash/index.html? /foo/bar should be served?
RewriteRule /splash/index\.html - [R=503]

Open in new window

Avatar of linuxraja

ASKER

After adding this its Providing syntax error while restarting apache

RewriteRule: invalid HTTP response code for flag 'R'
> RewriteRule: invalid HTTP response code for flag 'R'

> "If you're on apache 2.2"

So you're not on apache 2.2 but on an older branch, hence you can't issue a 503 with mod_rewrite.

What you can do is to rewrite (internally) to some script, e.g. php or perl or whatever and use the header/status functions to set a http status code provided by the language of you choice.
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^192\.168\.
RewriteRule /splash/index\.html /internal-script.php [L]

Open in new window

This seems good. Can you give me the content of  internal-script.php script
ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial