Apache Redirection

Posted on 2009-03-30
Last Modified: 2012-05-06
   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.
Question by:linuxraja
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 27

Expert Comment

ID: 24018344
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


Author Comment

ID: 24018950
After adding this its Providing syntax error while restarting apache

RewriteRule: invalid HTTP response code for flag 'R'
LVL 27

Expert Comment

ID: 24019275
> 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


Author Comment

ID: 24133677
This seems good. Can you give me the content of  internal-script.php script
LVL 27

Accepted Solution

caterham_www earned 500 total points
ID: 24135270
Something like

header("HTTP/1.0 503 Service Unavailable");
header("Status: 503 Service Unavailable");

Open in new window


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
.htaccess rewrite url with querystring problem 13 114
Setting up a WAMP server... 7 68
Apache error.log 19 72
Apache LDAP Authentication 20 53
As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question