Need to allow encoded slashes on Apache

后端 未结 7 2024
我寻月下人不归
我寻月下人不归 2020-11-30 20:12

I\'m currently trying to place a URL within a URL. For example:

http://example.com/url/http%3A%2F%2Fwww.url2.com

I\'m aware that I have to

7条回答
  •  醉酒成梦
    2020-11-30 20:59

    I kept coming across this post for another issue. Let me just explain real quick.

    I had the same style URL and was also trying to proxy it.

    Example: Proxy requests from /example/ to another server.

    /example/http:%2F%2Fwww.someurl.com/
    

    Issue 1: Apache believes that's an invalid url

    Solution: AllowEncodedSlashes On in httpd.conf

    Issue 2: Apache decodes the encoded slashes

    Solution: AllowEncodedSlashes NoDecode in httpd.conf (Requires Apache 2.3.12+)

    Issue 3: mod_proxy attempts to re-encode (double encode) the URL changing %2F to %252F (eg. /example/http:%252F%252Fwww.someurl.com/)

    Solution: In httpd.conf use the ProxyPass keyword nocanon to pass the raw URL thru the proxy.

    ProxyPass http://anotherserver:8080/example/ nocanon
    

    httpd.conf file:

    AllowEncodedSlashes NoDecode
    
    
      ProxyPass http://anotherserver:8080/example/ nocanon
    
    

    Reference:

    • http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
    • http://www.silverdisc.co.uk/blog/2009/02/28/url-canonicalisation-and-normalisation
    • Cannot match %2F in mod_rewrite

提交回复
热议问题