.htaccess将www重写为非www,但robots.txt除外

时间:2015-09-08 07:56:02

标签: .htaccess robots.txt

工作正常,但将www.site.com/robots.txt重定向到site.com/robots.txt 我尽量避免robots.txt重定向。需要添加什么?

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

1 个答案:

答案 0 :(得分:1)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !robots\.txt
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]