Author Topic: content switching problem  (Read 897 times)

Offline redwulf

  • Contributor
  • *
  • Posts: 1
  • Karma: 0
content switching problem
« on: January 12, 2012, 07:51:33 PM »
Hi,

I want to do a content switching per URL

example:

name.mydomain.com/tr/  --> should be redirected to testing websites
name.mydomain.com/st/ --> should be redirected to staging websites
name.mydomain.com/pr/ --> should be redirected to production websites

I used this expression to do that REQ.HTTP.URL CONTAINS /ts/website1, but when one of my website that has link same to /tr like /st/transaction, the redirection fails.

Please help.

How can ensure that only URL's under /tr should be redirected/forwarded to /tr website even if there is a context similar to the rest of urls.

One workaround i did to resolve this is by re-arranging the priority but it is tedious to manage that when your have let's say 20 to 50 URLs.

Offline mkalle

  • VIP Member
  • ***
  • Posts: 25
  • Karma: 1
Re: content switching problem
« Reply #1 on: January 12, 2012, 10:42:34 PM »
you could do a regex match.

HTTP.REQ.URL.REGEX_MATCH(re-^/tr/.*-) -> goes to
HTTP.REQ.URL.REGEX_MATCH(re-^/st/.*-) -> goes to
HTTP.REQ.URL.REGEX_MATCH(re-^/pr/.*-) -> goes to

morten

Offline Paul B

  • Hero Member
  • *****
  • Posts: 193
  • Karma: 20
Re: content switching problem
« Reply #2 on: January 20, 2012, 06:53:45 AM »
Hi,

I want to do a content switching per URL

example:

name.mydomain.com/tr/  --> should be redirected to testing websites
name.mydomain.com/st/ --> should be redirected to staging websites
name.mydomain.com/pr/ --> should be redirected to production websites

I used this expression to do that REQ.HTTP.URL CONTAINS /ts/website1, but when one of my website that has link same to /tr like /st/transaction, the redirection fails.

Please help.

How can ensure that only URL's under /tr should be redirected/forwarded to /tr website even if there is a context similar to the rest of urls.

One workaround i did to resolve this is by re-arranging the priority but it is tedious to manage that when your have let's say 20 to 50 URLs.

Content switching supports both Classic & Advanced policies: yours was a Classic, mkalle's was an Advanced one, using a regex, no big deal.

As you spotted, the problem with using "contains" is that incorrect things can also match it, so you need to use an "equals" with a wildcard instead, so you match "the string starts with '/tr/' then has anything else following it".....  something like "REQ.HTTP.URL==/tr/*" (Classic format) or HTTP.REQ.URL.EQ("/tr/*") (Advanced format) should give you what you want (without needing to understand regexes!).