I have a legacy site for a charity running on an old Apache 1.3 instance, behind Apache 2 running proxypass. When a request comes to example.com, Apache 2 sends it internally to localhost:8080 which works fine.
The problem:
example.com/blog/ works but example.com/blog (no trailing slash) does not. The URL it changes to in Chrome is example.com:8080/blog/ which doesn't exist.
The same is true for all other directories.
Apache 2:
<VirtualHost *:80>
ServerName example.com
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Apache 1:
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot /usr/www/html/
ServerName example.com
RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$
RewriteRule .* - [F]
</VirtualHost>
I thought a simple solution would be to add a rewriterule in either virtualhost but I've not had any success despite many attempts. I think a key issue is it's wrongly looking on example.com:8080 when the slash isn't there. It would be great if anyone can help me out, ask me any additional info that would be useful.
Best Answer
I see no
ProxyPassReverse
ormod_proxy_html
directives in your config; the lack ofProxyPassReverse
, specifically, is likely to be the cause of your issue as the backend Apache is sending a redirect to the slashful URL, but has it's internal name in the Location: header, and withoutProxyPassReverse
the frontend Apache is just letting that internal URL leak.mod_proxy_html
is for the equivalent issues, but in HTML rather than HTTP headers. It's also worth using, unless you're really sure nobody's going to go putting a full URL in the HTML (which, for any dynamic webapp, is a bad bet).