简体   繁体   English

Apache 重写 QUERY_STRING 以 & 开头

[英]Apache rewrite QUERY_STRING starts with &

I have a URL starts with a "&" at the beginning of the query string.我有一个 URL 以查询字符串开头的“&”开头。

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.我想将以 & 开头的查询字符串重定向到相同的 URL 但开头没有 &。

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 https:/.htaccess.madewithlove.com?share=26758c0f-cc73-4400-a525-c540d0b8ca65

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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