mod_rewrite behavior when port is specified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello..

I'm seeing an issue where mod_rewrite seems to behave differently when the client connects to my VirtualHost and includes the port as a part of the URL.  i.e.  http://xenial.localdomain vs. http://xenial.localdomain:80

With this RewriteRule, the redirection that I want (to my SSL VirtualHost listening on port 443) is working just fine as long as the client uses http://xenial.localdomain as the URL:

RewriteRule ^/?(.*) https://%{HTTP_HOST}:443/$1 [R=301,L]

However, when the port is specified ( http://xenial.localdomain:80 ), the redirect does not work as expected.  I see the following in my logs:

192.168.122.1 - - [06/Mar/2017:18:57:58 +0000] "GET / HTTP/1.1" 301 595 "-" "Links (2.13; Linux 4.8.13-100.fc23.x86_64 x86_64; GNU C 5.3.1; text)"
192.168.122.1 - - [06/Mar/2017:18:57:58 +0000] "GET /https://xenial.localdomain:80:443/ HTTP/1.1" 301 662 "-" "Links (2.13; Linux 4.8.13-100.fc23.x86_64 x86_64; GNU C 5.3.1; text)"
192.168.122.1 - - [06/Mar/2017:18:57:58 +0000] "GET /https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/ HTTP/1.1" 301 798 "-" "Links (2.13; Linux 4.8.13-100.fc23.x86_64 x86_64; GNU C 5.3.1; text)"
192.168.122.1 - - [06/Mar/2017:18:57:58 +0000] "GET /https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/ HTTP/1.1" 301 1070 "-" "Links (2.13; Linux 4.8.13-100.fc23.x86_64 x86_64; GNU C 5.3.1; text)"
192.168.122.1 - - [06/Mar/2017:18:57:58 +0000] "GET /https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/https://xenial.localdomain:80:443/ HTTP/1.1" 301 1614 "-" "Links (2.13; Linux 4.8.13-100.fc23.x86_64 x86_64; GNU C 5.3.1; text)"

As you can see, a '/' is being prepended to the rewritten URL and recursion occurs which eventually causes the URL to become too long and cause an error.  Why does specifying the port in the URL cause mod_rewrite to behave differently?  Is there a better way for me to do this?

Normally, this wouldn't be an issue, but I need to be able to run this VirtualHost on a port other than 80.

Thanks in advance for any suggestions...Paul..


---

Paul B Schroeder <paul.schroeder "at" nimbix "dot" net>

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux