.htaccess 将 www 重写为非 www,除了 robots.txt
.htaccess rewrite www to non-www except robots.txt
工作正常,但将 www.site.com/robots.txt
重定向到 site.com/robots.txt
我尽量避免 robots.txt 重定向。需要补充什么?
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !robots\.txt
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
工作正常,但将 www.site.com/robots.txt
重定向到 site.com/robots.txt
我尽量避免 robots.txt 重定向。需要补充什么?
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !robots\.txt
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]