Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
.htaccess 如果来自谷歌,将测试链接重定向到旧链接_.htaccess_Seo - Fatal编程技术网

.htaccess 如果来自谷歌,将测试链接重定向到旧链接

.htaccess 如果来自谷歌,将测试链接重定向到旧链接,.htaccess,seo,.htaccess,Seo,所以,在为客户做项目时,.htaccess的一些问题会导致测试URL被Google引用。这不是超级 因此,我想知道当somebod将其添加到web根目录中的.htaccess时是否可以重定向到live URL RewriteEngine on RewriteBase / RewriteCond %{HTTP_USER_AGENT} googlebot [NC,OR] RewriteCond %{HTTP_REFERER} ://[^.]+\.google\. [NC] RewriteRule

所以,在为客户做项目时,
.htaccess
的一些问题会导致测试URL被Google引用。这不是超级


因此,我想知道当somebod将其添加到web根目录中的
.htaccess
时是否可以重定向到live URL

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_USER_AGENT} googlebot [NC,OR]
RewriteCond %{HTTP_REFERER} ://[^.]+\.google\. [NC]
RewriteRule ^test/page\.php$ http://domain.com/live/page.php [R=301,NC,L]

您可以使用以下规则:

##  check if it is coming from google
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?google\. [NC] 
RewriteRule ^test/?$ /live/ [NC,L,R=301]

问题是,我们仍然需要访问测试一,好吧,测试:)它只需要来自谷歌时:/您正在生产上测试?:)我们有两个不同的服务器,但我们在某个时候意外删除了.htpasswd,一个页面有时间被索引。。。不管怎么说,它似乎有效,谢谢:)