我有一个基本结构的WordPress网站:URL关键字分隔符符号是/。问题是我创建的页面可以使用URL中的/或+符号进行访问。
我的意思是,我可以在mydomain.com/example-page/和mydomain.com/example+page/访问同一页面。我知道这对SEO有害所以我提出一个问题:是否可以通过htaccess将noindex nofollow命令设置为在URL中使用+符号分隔符的所有页面?
如果您有更好的解决方案,我将不胜感激!
答案 0 :(得分:0)
您可以使用(在实际的htaccess代码之前):
RewriteEngine on
# executes repeatedly as long as there are more than 1 spaces in URI
RewriteRule "^(\S*)\s+(\S*\s.*)$" /$1-$2 [L,NE]
# executes when there is exactly 1 space in URI
RewriteRule "^(\S*)\s(\S*)$" /$1-$2 [L,R=302,NE]
谁将版本示例+页面重定向到example-page