[英]htacess redirect - changing the query part of a URL
Google picked up the following URL and ranked it: Google选择了以下URL并对其进行了排名:
http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1 (the item_id=99 part should not be there). http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1 (不应该存在item_id = 99部分)。
Since I picked up the error and fixed it, I have added the following line to my htaccess: 由于我发现并修复了该错误,因此将以下行添加到了htaccess中:
RedirectPermanent /yyy/zzz-99.php?item_id=99&sort=1 http://www.example.com/yyy/zzz-99.php?&sort=1
However that redirect does not work. 但是,该重定向不起作用。 Any clue on what i am doing wrong?
关于我在做什么错的任何线索吗?
I think you need mod_rewrite to achieve even that single replacement, because includes a query string. 我认为您甚至需要mod_rewrite来实现该单个替换,因为其中包括一个查询字符串。
You may try this in the .htaccess file in root directory, provided mod_rewrite is enabled: 您可以在根目录的.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]
Redirects 重新导向
http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1
to http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1
至
http://www.example.com/yyy/zzz-99.php?&sort=1
For silent mapping, remove R=301 from [NC,L,R=301]. 对于静默映射,从[NC,L,R = 301]中删除R = 301。
Check the name of your .htaccess file. 检查您的.htaccess文件的名称。 Make sure it starts with a period.
确保它以句点开头。
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
use 301 redirect in .htaccess: 在.htaccess中使用301重定向:
Redirect 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 http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1 http://www.example.com/yyy/zzz-99.php?sort=1
Redirect 301 (from) (to) 重定向301(从)(至)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.