开发者

503 server response for Googlebot

开发者 https://www.devze.com 2023-01-03 18:45 出处:网络
I put an .htaccess file in my webroot with the following contents RewriteBase / RewriteCond %{HTTP_USER_AGENT} ^.*(Googlebot|Googlebot|Mediapartners|Adsbot|Feedfetcher)-?(Google|Image)? [NC]

I put an .htaccess file in my webroot with the following contents

RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^.*(Googlebot|Googlebot|Mediapartners|Adsbot|Feedfetcher)-?(Google|Image)? [NC]
RewriteRule .* /var/www/503.html

This website is in maintenance mode, and I don't want anything indexed yet. I tested the code with a firefox User-Agent switcher plugin, and looking at the access log it shows this at the end of each log entry, but watching in TamperData or Firebug, it still returns a 200 server response instead of a 503. What am I doing wrong?

"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

contents of /var/www/503.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>503 - Service temporary unavailable</title>
</head>
<body>
<h1>503 - Service temporary unavailable</h1>
<p>Sorry, this website is currently down for maintainance please
retry later</p>
</body>
</html>

:::EDIT::: Added small snippet from the rewrite.log Here is a small sample, I went thru the entire log, and everything is referring to a javascript or image file:

172.16.173.26 - - [15/Jun/2010:15:03:31 --0500] [qa-test.com/sid#2b6c1c8ba938][rid#2b6c24cfdd18/initial] (4) [perdir /var/www/qa-test.com/web/] RewriteCond: input='' pattern='^.*(Googlebot|Googlebot|Mediapartners|Ad开发者_运维知识库sbot|Feedfetcher)-?(Google|Image)?' [NC] => not-matched


You have an infinite loop. The result of your rewrite is being rewritten again.

RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (?:Googlebot|Googlebot|Mediapartners|Adsbot|Feedfetcher)-?(?:Google|Image)? [NC]
RewriteCond $0 !(?:^|/)503\.html$
RewriteRule .* /var/www/503.html [R=503]

As @BalusC pointed out, you also need the R flag.


Either use:

RewriteRule .* /var/www/503.html [R=503,L]

Or when you're not on Apache 2.x yet where the above construct is supported, then make it a 503.php page and set in top of code:

header("HTTP/1.1 503 Service Temporarily Unavailable"); 
0

精彩评论

暂无评论...
验证码 换一张
取 消