Forum Discussion
andrew_deackes_
Nimbostratus
Jul 16, 2014matches_regex replacement
Hi,
we are using an i-rule to perform some redirects for a site. A recent addition to the rule doesn't appear to be working as we wanted it and I'm aware matches_regex is not the best solution so how can we replace this:
elseif { $uri matches_regex {^/(uk|test|news|marketing)/.*/$ }} {
HTTP::respond 301 Location "https://www.company.com[HTTP::uri]default.page"
any advice appreciated.
thanks
A
2 Replies
- forsan
Altostratus
Hi Andrew,
try this out:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/uk*" - "/test*" - "/news*" - "/marketing*" { HTTP::respond 301 Location "https://www.company.com[HTTP::uri]default.page" } } }Regards Andréas
- andrew_deackes_
Nimbostratus
Thanks Andreas, I might try that (we have a test environment). Someone also suggested using "ends_with" so might try that too like this, if I have the syntax right!:
elseif { [HTTP::uri] ends_with "/" } { HTTP::respond 301 Location "https://www.company.com[HTTP::uri]default.page" }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects