Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
Apache .htaccess 301重定向仅适用于google bot_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Apache .htaccess 301重定向仅适用于google bot

Apache .htaccess 301重定向仅适用于google bot,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我本质上是在试图用谷歌把我网站上的某些页面伪装成另一个页面。原因是我使用这个网站的付费流量,但我希望把搜索引擎优化流量发送到其他地方(通过301重定向),因为转换会更好 无论如何,这是我写的htaccess,但我不知道如何添加多个页面 RewriteEngine On RewriteCond %{HTTP_HOST} http://www.currentsite.com/ [NC] RewriteCond %{HTTP_HOST} http://www.currentsite.com/page

我本质上是在试图用谷歌把我网站上的某些页面伪装成另一个页面。原因是我使用这个网站的付费流量,但我希望把搜索引擎优化流量发送到其他地方(通过301重定向),因为转换会更好

无论如何,这是我写的htaccess,但我不知道如何添加多个页面

RewriteEngine On 
RewriteCond %{HTTP_HOST} http://www.currentsite.com/ [NC]
RewriteCond %{HTTP_HOST} http://www.currentsite.com/page1 [NC]
RewriteCond %{HTTP_USER_AGENT} Googlebot
RewriteRule ^(.*)$ http://www.newsite.com/ [L,R=301]
RewriteRule ^(.*)$ http://www.newsite.com/page1 [L,R=301]
我想你可以看到我想要实现的目标,将page1重定向到page1等等

谢谢


Morgan

在主文件夹中创建一个包含以下内容的
robots.txt

User-agent: *
Disallow: /page_to_hide1
Disallow: /page_to_hide2
Disallow: /page_to_hide3
在此处查找更多信息:

RewriteCond
仅使用紧跟其后的第一条
重写规则。您可以使用:

RewriteEngine On 
RewriteCond %{HTTP_HOST} http://www.currentsite.com/ [NC]
RewriteCond %{HTTP_USER_AGENT} Googlebot
RewriteRule ^(page1|page2|page3|etc)$ http://www.newsite.com/$1 [L,R=301]

你需要
robots.txt
,而不是
.htaccess
你不能通过robots.txt进行301重定向?这不是301重定向页面,这只是不索引某些页面。这就是
robots.txt
的目的-告诉谷歌(对于eample)您不希望某些页面被索引。但我希望重定向某些页面。我从来没有说过不给它们编制索引