0

When a user types in www.example.co.uk/beta, I want the traffic to be sent to www.example.co.uk/beta/. But only for that url ie, when the url ends /beta.

How do I accomplish this in apache?

I have tried:

<Location /beta>
    DirectorySlash Off
    ProxyPass  http://testserver.co.uk
    ProxyPassReverse http://testserver.co.uk
</Location>

With no success

Please note the proxypass directives are for my reverse proxy

2 Answers 2

1

A simple rewrite rule to deal with the traling slash; straight from the apache manual

RewriteEngine  on
RewriteRule    ^/beta$  /beta/  [R]
1
  • Thanks. What I was mistakenly failing to realise was the location directive picks up both /beta and /beta/ and /beta/whatever etc. Adding that regex condition of $ at the end forces it to match only /beta and not /beta/ etc. Of course I put that rewrite rule inside the location Jan 9, 2014 at 9:08
1

Many ways to do it you might want to do it this way:

<Proxy /beta>
   ProxyPass http://testserver.co.uk/beat/
   ProxyPassReverse http://testserver.co.uk/beta/ 
</Proxy>

This will work also:

ProxyPass  /beta http://testserver.co.uk/beat/
ProxyPassReverse /beta http://testserver.co.uk/beta/ 

You could also use ProxyPassMatch:

ProxyPassMatch ^(/beta)$ http://testserver.co.uk/$1/
ProxyPassReverse $1 http://testserver.co.uk/$1/

You can find out more here.

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.