【发布时间】:2013-12-21 02:54:49
【问题描述】:
我有以下重写规则:
RewriteRule ^places/([^/]+)$ PlaceD.php?LF=F&LFC=Place&PlaceID=$1
但是当我按如下方式调用 URL 时(当有 % 标记时)它会被忽略:
http://mydomain/places/sri-maha-bhodi-%2F-bodiya
但以下作品(没有 % 标记):
http://mydomain/places/sri-maha-bhodi-2F-bodiya
请问我应该如何更改重写规则?
【问题讨论】:
-
%2F 确实是个大问题,尽量避免出现在url中。要解决这个问题,请在 httpd.conf 中添加“AllowEncodedSlashes on”(不在 .htaccess 中),并在 RewriteRule 中将 ([^/]+) 更改为 (.+)。
-
@Andrew 的评论非常有用,但出于安全原因,最好使用
AllowEncodedSlashes NoDecode。 Read more about it here
标签: apache .htaccess mod-rewrite