I have an Apache web server that needs to reverse proxy a site. So example.com/test/ or example.com/test pull from the same other webserver. I have setup a reverse proxy for the one without the trailing slash like this:

ProxyPass /test http://othersite.com/test
ProxyPassReverse /test http://othersite.com/test

But it doesn't work with a trailing slash.

Any Ideas? I have tried redirecting from /test/ to /test with no luck.



Have you tried to rewrite the url?

RewriteEngine on 
RewriteRule ^/test$ /test/ [R]

ProxyRequests Off       
ProxyPreserveHost On

ProxyPass    /test/   http://othersite.com/test/
ProxyPassReverse /test/  http://othersite.com/test/
| improve this answer | |

What do you mean it doesn't work with a trailing slash? Does it redirect to the wrong place? Does it give a 404 error? This is what I used to set up a reverse proxy and hide the source from the rest of the world.

ProxyRequests off
<Location /guides>
  ProxyPass http://blog.domain.com
  ProxyPassReverse http://blog.domain.com
  ProxyPassReverse /
  ProxyHTMLEnable On
  ProxyHTMLURLMap / /guides
  ProxyHTMLURLMap http://blogs.domain.com /guides
  RequestHeader unset Accept-Encoding
  RequestHeader set MySpecialHeader secretkey
  #LogLevel proxy:debug

You can use this to test your proxy:

$ curl -I http://localhost:81/guides/top5
HTTP/1.1 301 Moved Permanently
Location: http://localhost:81/guides/top5/
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.