简体   繁体   中英

htaccess redirect double query string

Due to a coding error I have a bunch of false URLs that need to be rewritten in htaccees.

The query part of the URL got somehow duplicated and must now be stripped down to a single query part, eg

http://www.example.com/?abc=def/?abc=def to http://www.example.com/?abc=def

I was hoping to find a solution with wildcards so that it would work whenever a double query string occurs - regardless of the query. However my coding skills are not good enough to do so ...

I hope you can help! :-)

Try :

RewriteEngine on

RewriteCond %{THE_REQUEST} /\?abc=(.+?)/\?abc= [NC]
RewriteRule ^ /?abc=%1 [L,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM