A redirect written using mod_rewrite is broken when the URL uses a literal IPv6 address, the redirect location is missing the square brackets around the IPv6 address. To test set the following two rewrite rules RewriteRule ^/a/ /A/ [R,L] RewriteRule ^/c/ C/ [R,L] Let's say the server's IPv6 address is fd35:299:14bc:0:21d:50ff:fe00:1a, then with http://[fd35:299:14bc:0:21d:50ff:fe00:1a]/a/ the redirect location is http://fd35:299:14bc:0:21d:50ff:fe00:1a/a/ and similar for /c. This issue has been fixed with other mod_alias redirects and mod_proxy but it is still present in mod_rewrite as of 2.2.21.
Created attachment 28421 [details] Proposed patch This patch fixed the problem for me, tested with IPv6 and IPv4 literals as well as hostname in original URL, using both defined redirects "/a/" and "c/".
Hi and sorry for the late answer. This has been fixed in 2.3.5 (now 2.4.x branch) in r900022 a few years ago. The patch is not exactly the same as the one proposed here, but it does the same thing (i.e. turn 'ap_get_server_name' into 'ap_get_server_name_for_url' where needed) I've chosen to propose for backport the same version as the one in the 2.4.x branch. (see r1678492)
I actually saw that this was fixed in 2.3.5 just last Friday while porting our local patches from 2.2.x to 2.4.x :-) Thanks for proposing to backport to 2.2.x branch.
Backport to 2.2.30 accepted, will be in next release.