apache - 具有 IPv6 IP 地址的 RewriteRule 不起作用

标签 apache mod-rewrite ipv6

我在代理 IPv6 地址内的请求时遇到问题。

在 .htaccess/apache2.conf 上,我有它:

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

它工作正常,因为它是 IPv4 地址。 但是,它不起作用:

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

为什么?

错误日志:

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

最佳答案

这是因为[ & ]。 URL 中通常不允许使用这些字符,因此服务器将其转义为 %b5%5d。为了防止这种情况,请在重写规则中使用 NE 标志:

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

关于apache - 具有 IPv6 IP 地址的 RewriteRule 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46609891/

相关文章:

php - 特定页面的 apache 重写规则问题

java - HttpClient 4.2.3 - 连接重置异常

apache - 启动Zookeeper集群。错误:找不到或加载主类org.apache.zookeeper.server.quorum.QuorumPeerMain

php - 移动媒体 wiki 目录后出现 500 服务器错误

php - 在 ubuntu 服务器中为 php 启用 .htaccess

c - 打开源和目的地之间的UDP套接字,修改它并将其转发到原始目的地

ios - 在 iOS 中通过 ipv4 而不是 ipv6 路由网络

PHP 不被 apache 解释

java - WSO2 Get UserInfo 返回错误 java null 异常

Linux IPV6 主地址和辅助地址