开发者

Is there some Apache config that can filter out double-slash from URL?

I have web software where I need to have URLs like this

http://site.com/page/var1/val1/var2//var3/val3

Then I catch such URLs in .htaccess, redirect to a php file which then parses that to $_GET and forwards everything to main app. That double-slash is important, it means that var2 has been set and contains an empty value, in other words $var2!==NULL.

On some servers it works as expected but on some servers it doesn't, the URL is silently converted to

http://site.com/page/var1/val1/var2/var3/val3

which of course breaks everything because it parses it to $var1='val1', $var2='var3', $val3=''.

Unfortunately I already don't have access to one of those servers and I don't remember 100% whether it was Apache or not but let's assume it was Apache since that's the server we deal 开发者_JAVA百科with most of the time.

Is there may be some config that controls that? That turns on/off the cleaning of double-slashes.


Apache strips such empty path segments before mapping it onto the file system. To get the original requested URI in mod_rewrite, check the request line in %{THE_REQUEST}:

RewriteCond %{THE_REQUEST} ^GET\ (/[^?\ ]*)
RewriteRule …

You can then reference the match of RewriteCond with %1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜