vdTOG
vdTOG

Reputation: 21

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

Upvotes: 2

Views: 2012

Answers (1)

Webdesigner
Webdesigner

Reputation: 1982

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

Upvotes: 3

Related Questions