问题.htaccess使用301重定向与params

时间:2016-07-29 08:30:44

标签: php .htaccess

我想阻止参数被加入到url

问题.htaccess我有网站说example.com

1:我必须重定向

example.com/deatils.php?366%2520WORDS%2520IN%2520MUMBAI example.com/bookshelf/366_words_in_mumbai

我在下面写了代码

RewriteRule ^deatils.php?366%2520WORDS%2520IN%2520MUMBAI example.com/bookshelf/366_words_in_mumbai [R=301,L]
但是打开了 example.com/deatils.php?366%2520WORDS%2520IN%2520MUMBAI

重定向至example.com/bookshelf/366_words_in_mumbai?366%252520WORDS%252520IN%252520MUMBAI

我不希望字符串“?”被提出

1 个答案:

答案 0 :(得分:0)

将此附加规则用于htaccess中的重定向,它将对您有用。

RewriteCond %{QUERY_STRING} (^|&)366%2520WORDS%2520IN%2520MUMBAI($|&)
RewriteRule ^deatils\.php$ /bookshelf/366_words_in_mumbai? [L,R=301]