RewriteRule with an IPv6 IP address does not work

一笑奈何 提交于 2020-01-23 02:51:28

问题


I am having problems to proxy requestions inside a IPv6 address.

On .htaccess/apache2.conf, I have it:

RewriteRule (.*) http://18.4.15.8:80/path/$1 [P,L]

It works fine, because it is a IPv4 address. But, it does not works:

RewriteRule (.*) http://[27:ec:20:22:15::d3]:80/path/$1 [P,L]

Why?

Error Log:

Proxy Error

Your browser sent a request that this server could not understand. The proxy server could not handle the request GET /index.html.

Reason: URI cannot be parsed: http://%5b27:ec:20:22:15::d3%5d:80/path/index.html


回答1:


It's because of [ & ]. Thay are usually not allowed in a URL and so the server is escaping it to %b5and %5d. To prevent this use the NE Flag in your Rewrite Rule:

RewriteRule (.*) http://[27:ec:20:22:15::d3]:80/path/$1 [NE,P,L]

https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_ne



来源:https://stackoverflow.com/questions/46609891/rewriterule-with-an-ipv6-ip-address-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!