【发布时间】:2016-03-30 20:26:12
【问题描述】:
我有一个带有编码斜杠 (%2F) 的 URL,我无法获得重写规则来正确捕获它。
我的网址是:
http://example.com/some-path/description%2Frest-of-description/1101
我尝试过如下重写:-
# is the %2F interpreted as a path separator
RewriteRule ^some-path/(.*)/(.*)/(.*)$ /property/view?ref=$3 [B,R=301,L]
# or is it as an encoded string
RewriteRule ^some-path/(.*)%2F(.*)/(.*)$ /property/view?ref=$3 [B,R=301,L]
# or even double encoded
RewriteRule ^some-path/(.*)%252F(.*)/(.*)$ /villas/$1-$2/$3 [B,R=301,NE,L]
我也尝试在上面添加QSA。
在 SO here 上有一个类似的问题,但它是基于 IIS 和 .NET 的
我正在运行 LAMP 堆栈
【问题讨论】:
-
@Nikhil 您应该将其添加为答案(提供更多信息)。
-
我尝试将 AllowEncodedSlashes On 添加到虚拟主机并在所有请求中获得 500 ... apache 2.4
-
只是为了确认一下,使用
AllowEncodedSlashes Off(默认)你会得到系统生成的 404(即服务器的默认404,而不是自定义的404页面)吗?跨度>
标签: php apache .htaccess mod-rewrite url-rewriting