我正在尝试通过htaccess执行简单的301重定向,重定向可以正常工作,但会在网址中添加“?folder = X”。
例如:
Redirect 301 /pets http://www.mydomain.com/discount-pet-products
返回:
http://www.mydomain.com/discount-pet-products?folder=pets
如何删除?
这是我的htaccess文件
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
Redirect 301 /pets http://www.mydomain.com/discount-pet-products
RewriteRule ^([0-9a-zA-Z-]+)$ load.php?folder=$1 [L]
答案 0 :(得分:0)
试试这个:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^/pets$ http://www.mydomain.com/discount-pet-products? [R=301,L]
RewriteRule ^([0-9a-zA-Z-]+)$ load.php?folder=$1 [L]
答案 1 :(得分:0)
试试这段代码:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^pets/$ /discount-pet-products? [R=301,L]
RewriteRule ^([0-9a-zA-Z-]+)/?$ load.php?folder=$1 [L,QSA]
请务必在新浏览器中对此进行测试,以避免出现浏览器缓存问题。
答案 2 :(得分:0)
答案是将重定向放在.htaccess文件的顶部,在任何事情之前
RewriteRule ^pets$ http://www.mydomain.co.uk/discount-pet-products [R=301,L]