23

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.

2 Answers 2

32

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.

3
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
1
  • This should be the accepted answer, far easier to setup for complex setups. Commented Aug 1, 2022 at 9:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .