0

根据谷歌的建议,我尝试在我的 .htaccess 中添加一些代码以防止重复内容。这是我的代码:

#Duplicate Content
RewriteCond %{HTTP_HOST} !^www.soomar63.com$ [NC]
RewriteRule ^(.*)$ http://www.soomar63.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://www.soomar63.com/ [R=301,L]
#Remove Trailing Slash
RewriteCond %{HTTP_HOST} ^(www.)?soomar63\.com$ [NC]
RewriteCond %{THE_REQUEST} !administrator/(.*)$
RewriteRule ^(.*)/$ http://www.soomar63.com/$1 [R=301,L]

这段代码运行良好,只是有一个小问题:

此代码更正以下链接:

soomar63.com -> www.soomar63.com
soomar63.com/ -> www.soomar63.com
soomar63.com/index.php/ -> www.soomar63.com
soomar63.com/about.html/ -> www.soomar63.com/about.html

但它不纠正以下链接:

soomar63.com/index.php?mylink/ -> must correct to www.soomar63.com/index.php?mylink
soomar63.com/about.html#mylink/ -> must correct to www.soomar63.com/about.html#mylink

请帮忙。谢谢你。

4

1 回答 1

0

#Remove Trailing Slash用下面的规则替换你的规则

#Remove Trailing Slash

RewriteCond %{HTTP_HOST} ^(www.)?soomar63\.com$ [NC]
RewriteCond %{THE_REQUEST} !^/?administrator$
RewriteRule ^ http://www.soomar63.com%{REQUEST_URI} [R=301,L,QSA]
于 2014-04-01T11:10:43.620 回答