简体   繁体   中英

Apache rewrite QUERY_STRING starts with &

I have a URL starts with a "&" at the beginning of the query string.

www.example.com/index.htm?&parameter1=value1&parameter2=value2

I would like to redirect a query string that starts with a & to the same URL but without the & at the beginning.

Request

www.example.com/index.htm?&parameter1=value1&parameter2=value2

Result

www.example.com/index.htm?parameter1=value1&parameter2=value2

I have already made several attempts but can't get the correct rule.

Sounds pretty straight forward:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^&(.*)$
RewriteRule ^ %{REQUEST_URI}?%1 [R=301,L]

Seems to work:

https:/.htaccess.madewithlove.com?share=26758c0f-cc73-4400-a525-c540d0b8ca65

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