.htaccess文件重定向后添加特殊字符

时间:2015-10-19 12:12:48

标签: .htaccess url-rewriting

我的查询字符串中有破折号,重定向后从.htaccess文件变为%252d pls检查下面提到htaccess规则

RewriteCond %{THE_REQUEST} ^GET\ /hotels-details\?hotelcode=(\S+)&hotel_key=(\S+)&hnm=(\S+)&hct=(\S+) [NC]
RewriteRule ^ /hotel/%3-in-%4-%1-%2? [R=301,L,B]
RewriteRule ^hotel/(.*)-in-(.*?)-(\d+)-(\d+)/?$ /hotels-details/hotelcode=$3&hotel_key=$4&hnm=$1&hct=$2 [L]

1 个答案:

答案 0 :(得分:1)

您需要删除B标记并使用它:

RewriteCond %{THE_REQUEST} /hotels-details\?hotelcode=([^\s&]+)&hotel_key=([^\s&]+)&hnm=([^\s&]+)&hct=([^\s&]+) [NC]
RewriteRule ^ /hotel/%3-in-%4-%1-%2? [R=301,L,NE]

RewriteRule ^hotel/([^-]+)-in-([^-]+)-(\d+)-(\d+)/?$ hotels-details/hotelcode=$3&hotel_key=$4&hnm=$1&hct=$2 [L,QSA]