我的查询字符串中有破折号,重定向后从.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]
答案 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]