21

I am using Apache 2.2.15 on CentOS to provide SSL for a TomCat application.

ProxyPass / http://127.0.0.1:8090/ connectiontimeout=300 timeout=300
ProxyPassReverse / http://127.0.0.1:8090

This works fine and everything is great; however, I want to add the following line:

Redirect permanent /broken/page.html https://www.servername.com/correct/page.html

before the above to handle an error in the TomCat application itself. However, it does not appear to work the way I expect (i.e, it appears to do nothing and change nothing). Is it possible to use Redirect this way? I don't have the ability to edit the application, unfortunately.

bombcar
  • 313
  • 1
  • 2
  • 5

2 Answers2

30

Yes! Above the ProxyPass /, add:

ProxyPass /broken/page.html !

That'll force the proxypass to not act on the page that you're trying to redirect.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
13

<Proxy> blocks are also useful as the context is always understood to be applying to proxied traffic. In this fashion you don't need to exclude specific paths.

<Proxy *>
    Redirect permanent /broken/page.html https://www.example.com/correct/page.html
    RedirectMatch ^/deadstuff.+ http://www.example.com/correct/page.html
</Proxy>

ProxyPass / http://127.0.0.1:8090/ connectiontimeout=300 timeout=300
ProxyPassReverse / http://127.0.0.1:8090
Andrew B
  • 31,858
  • 12
  • 90
  • 128