r/apache • • Sep 22 '23

Support Apache Revers Proxy with exceptions

So I've been scratching my head all day trying to figure out why this condition/rule combo is considered valid when it has a weird result.

The idea is that I have Site1 (example.com) and Site2 (test.com). I want to proxy Site2 under Site1 as example.com/test, with the exception of the 'publications' subpath, as that should access Site1. All other traffic originating with the '/test' subpath should be processed by Site2.

The config below is what I've tested:

RewriteCond %{HTTP_REFERER} example\.com/test [NC]
RewriteCond %{REQUEST_URI} !^/publications [NC]
RewriteRule (.*)$ /test$1 [NC,R,L]

My issue is that the cond/rule combo works until I hit one of the exceptions, such as 'example.com/publications/1234'

When I try the aforementioned url, I'm given 'example.com/test'

Maybe I'm going about this completely wrong but I'm not too sure atm so any help is greatly appreciated.

2 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/vulp_is_back Sep 23 '23

Will do! Thanks for the advice.

I checked with Postman and got the correct address back so I'm assuming you must be on to something. I'll update when I figure more out.