Looking for equivalent of ProxyPassReverseMatch in Apache to fix missing trailing forward slash issue
Posted
by
Alex Man
on Server Fault
See other posts from Server Fault
or by Alex Man
Published on 2011-01-06T03:42:57Z
Indexed on
2011/01/06
3:55 UTC
Read the original article
Hit count: 384
I have two web servers, www.example.com and www.userdir.com. I'm trying to make www.example.com as the front end proxy server to serve requests like in the format of http://www.example.com/~username such as
http://www.example.com/~john/
so that it sends an internal request of
http://www.userdir.com/~john/
to www.userdir.com. I can achieve this in Apache with
ProxyPass /~john http://www.userdir.com/~john ProxyPassReverse /~john http://www.userdir.com/~john
The ProxyPassReverse is necessary as without it a request like http://www.example.com/~john without the trailing forward slash will be redirected as http://www.userdir.com/~john/ and I want my users to stay in the example.com space.
Now, my problem is that I have a lot of users and I cannot list all those user names in httpd.conf. So, I use
ProxyPassMatch ^(/~.*)$ http://www.userdir.com$1
but there is no such thing as ProxyPassReverseMatch in Apache. Without it, whenever the trailing forward slash is missing in the URL, one will be directed to www.userdir.com, and that's not what I want.
I also tried the following to add the trailing forward slash
RewriteCond %{REQUEST_URI} ^/~[^./]*$ RewriteRule ^/(.*)$ http://www.userdir.com/$1/ [P]
but then it will render a page with broken image and CSS because they are linked to http://www.example.com/images/image.gif while it should be http://www.example.com/~john/images/image.gif.
I have been googling for a long time and still can't figure out a good solution for this. Would really appreciate it if any one can shed some light on this issue. Thank you!
© Server Fault or respective owner