Google选取了以下URL并对其进行了排名:
http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1 (item_id=99部分不应该在那里)。
由于我捡起了错误并修复了它,我在我的htaccess中添加了以下行:
RedirectPermanent /yyy/zzz-99.php?item_id=99&sort=1 http://www.example.com/yyy/zzz-99.php?&sort=1
但是,重定向不起作用。任何线索我做错了什么?
我认为您需要mod_rewrite来实现甚至单个替换,因为包含查询字符串。
你可以在根目录下的.htaccess文件中尝试这样做,前提是mod_rewrite是启用的:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/yyy/zzz-99'.php [NC]
RewriteCond %{QUERY_STRING} item_id=99&sort=1 [NC]
RewriteRule .* /yyy/zzz-99.php?&sort=1? [NC,L,R=301]
重定向 http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1
to
http://www.example.com/yyy/zzz-99.php?&sort=1
对于静默映射,从[NC,L,R=301]中删除R=301
检查.htaccess文件的名称。请确保以句号开头。
redirect 301 /index.html http://www.domain.com/index.html
redirect permanent /index.html http://www.domain.com/index.html
redirectpermanent /index.html http://www.domain.com/index.html
使用301重定向在。htaccess:
重定向301 http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1 http://www.example.com/yyy/zzz-99.php?sort=1
重定向301 (from) (to)