繁体   English   中英

如何修改503 htaccess规则以避免“ Googlebot无法访问您的网站”错误?

[英]How can I amend 503 htaccess rule to avoid 'Googlebot can't access your site' error?

在建设中时,我需要一个网站返回503。

我将访问者指向一个友好的“即将推出”页面,但是Google网站管理员工具报告“ Googlebot无法访问您的网站”。

这是.htaccess中的当前规则:

<IfModule mod_rewrite.c>
RewriteEngine On

# Allow Access Locally
RewriteCond %{REMOTE_ADDR} !^127.0.0.1

# Prevent 503 for Maintenance Page
RewriteCond %{REQUEST_URI} !/maintenance [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]

# Show Friendly 503
RewriteRule .* http://www.example.com/maintenance/index.php [R=503,L]
</IfModule>

它对访问者有效,但是如何修改规则以确保Google理解503?

在维护文件的标题中,我有:

<?php
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: Wed, 18 Jun 2014 01:00:00 GMT');
?>

我想Google正在尝试访问robots.txt。 这应该从503指令中排除吗?

谢谢

替换此行:

RewriteRule .* http://www.example.com/maintenance/index.php [R=503,L]

附:

RewriteRule !^503\.php$ /503.php [L,NC]

/503.php添加/503.php http_response_code(503)如下所示:

<?php
http_response_code(503);
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: Wed, 18 Jun 2014 01:00:00 GMT');
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM