简体   繁体   中英

RewriteRule with an IPv6 IP address does not work

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

It's because of [ & ] . Thay are usually not allowed in a URL and so the server is escaping it to %b5 and %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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM