3

At proxypass configuration file I have written this line

ProxyPass /directory/ ajp://localhost:8009/directory/

It works perfectly

At htaccess file

RewriteRule ^seconddirectory/(.*)$ http://domain.com.localhost/directory/$1 [P]

P flag implies L.

This works too

If I use only [L] it works too. Anyway, will match with ProxyPass.

But I want the Proxy redirects via AJP only if a referer contains /action if not you can't use the ProxyPass

I tried to make a condition with RewriteCond

RewriteCond %{HTTP_REFERER}% !/action
RewriteRule .? - [S=2]
  RewriteRule ^seconddirectory/(.*)$ https://domain.com.localhost/directory/$1 [L]
  RewriteRule .? - [S=1]
RewriteRule ^seconddirectory/(.*)$ https://domain.com.localhost/404 [L]

If (referer no contains /action), in this case, is skipping 2 lines and is redirected to a 404 page

If the URL is

https://domain.com.localhost/seconddirectory/anything

I'm being redirected to https://domain.com.localhost/404

This is correct

If referer contains /action

I'm not beign redirected to https://domain.com.localhost/directory/$1

This is the referer where I come from https://domain.com.localhost/controller.php/module/atoken/action (referer)

Any suggestion?

2

What you're looking for is the [P] flag of RewriteRule. Something like this:

RewriteCond %{HTTP_HOST} ^alias.domain.com$ [I]
RewriteRule ^/(.*)$ http://myinternalserver.com/$1 [P,L]
  • I had changed the question but I have a little problem with the RewriteCond to match with the RewriteRule wtih the [P] flag. But this flag Is a posible solution to match a condition before execute the proxypass. Without this flag the ProxyPass will match first and the condition could not be executed before. Thank You – Jvrq Aug 3 '13 at 11:44

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.