Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 使用.htaccess阻止Googlebot访问以4-6位结尾的URL,正则表达式?_Regex_Apache_.htaccess - Fatal编程技术网

Regex 使用.htaccess阻止Googlebot访问以4-6位结尾的URL,正则表达式?

Regex 使用.htaccess阻止Googlebot访问以4-6位结尾的URL,正则表达式?,regex,apache,.htaccess,Regex,Apache,.htaccess,我们如何编写.htaccess来阻止Googlebot UA访问以正斜杠结尾,后跟4-6位数字的URL 我们浪费了大量的谷歌机器人爬网预算,因为它在爬网“无索引”页面 计划是使用.htaccess阻止UA访问以正斜杠结尾、后跟4-6位数字的URL 例: 我认为正则表达式看起来像这样: \/\d{4,6}$ 但是我如何配置.htaccess,并且仅针对特定的UA(谷歌机器人) 谢谢 您可以使用: RewriteEngine on RewriteCond ℅{HTTP_USER_AGENT} g

我们如何编写.htaccess来阻止Googlebot UA访问以正斜杠结尾,后跟4-6位数字的URL

我们浪费了大量的谷歌机器人爬网预算,因为它在爬网“无索引”页面

计划是使用.htaccess阻止UA访问以正斜杠结尾、后跟4-6位数字的URL

例:

我认为正则表达式看起来像这样:

\/\d{4,6}$
但是我如何配置.htaccess,并且仅针对特定的UA(谷歌机器人)

谢谢

您可以使用:

RewriteEngine on

RewriteCond ℅{HTTP_USER_AGENT} googlebot [NC]
RewriteRule /\d{4,6}$ - [F,L]
如果Google Bot试图访问您服务器上的受限URL,这将返回一个
禁止的HTTP 403错误

RewriteEngine on

RewriteCond ℅{HTTP_USER_AGENT} googlebot [NC]
RewriteRule /\d{4,6}$ - [F,L]