我希望访问者继续查看域名(www.example.com),但搜索引擎必须重定向到新网站(www.newsite.com)。
我只需要在主页上进行此重定向。我知道我可以用一个规范来实现这个目标,但是如果我想在htaccess中插入一些内容我该怎么做呢?
在this link我看到类似的东西(与我需要的相反),但我不知道如何调整它以适合我的需要。
这是我的htaccess(我可以把代码行放在哪里?)
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName example.it
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml
# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
# END WordPress
答案 0 :(得分:1)
从目的帮助链接中的答案中,删除感叹号!
:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^(110\.174\.129\.147|203\.217\.17\.162)
RewriteCond %{HTTP_USER_AGENT} (Googlebot|msnbot|Surp) [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NE]
所以在你的.htaccess例子中,改变一下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
对此:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^(110\.174\.129\.147|203\.217\.17\.162)
RewriteCond %{HTTP_USER_AGENT} (Googlebot|msnbot|Surp) [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NE]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
答案 1 :(得分:1)
好的,谢谢@RichardBernards .....它很棒...我删除了行代码
RewriteCond %{REMOTE_ADDR} ^(110\.174\.129\.147|203\.217\.17\.162)
现在没关系.....非常感谢