[英]Mod_rewrite: Redirect to URL in query string - discard %3f from end of redirected URL
我有一个.htaccess重写规则,该规则采用以下形式的传入请求:
IN 1) http://some.domain.com/path/to/index.htm?url=http://take.me/
IN 2) http://some.domain.com/path/to/index.htm?url=http://take.me/another/path/file.htm?key1=val1&key2+val2
我想做的是让规则提取url
键的值并重定向到它的值ergo:
OUT 1) http://take.me/
OUT 2) http://take.me/another/path/file.htm?key1=val1&key2=val2
以下条件和规则适用:
RewriteCond %{QUERY_STRING} ^url=(.*)$
RewriteRule ^index\.htm$ %1? [R,L]`
但是,在OUT 2的情况下,我发现在浏览器地址栏中看到的结果URL为:
http://take.me/another/path/file.htm?key1=val1&key2+val2%3f
因此,问题在于将%3f
(百分比编码的问号)附加到结果URL。 问题是由使用?
在RewriteRule中,但是我需要这样做,以便丢弃原始查询字符串。 我不知道%3f
是否会引起问题,因此为了安全起见,我想消除它。 我们正在使用Apache 2.2.22,因此不幸的是没有查询字符串丢弃[QSD]
选项。
有没有办法在维持规则功能的同时消除%3f
?
您可以将此规则与NE
标志一起使用,这意味着no escaping
结果URL:
RewriteCond %{THE_REQUEST} index\.htm\?url=(\S+) [NC]
RewriteRule index\.htm$ %1? [L,R=302,NC,NE]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.