Forum Discussion
Syntax errors on match_glob?
On https calls, detect no www and redirect to www
when HTTP_REQUEST {
if { [HTTP::host] matches_glob "blah*.com" } {
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
}
}
I get this:
01070151:3: Rule [BLAH_HTTPS_NO_WWW] error:
line 3: [parse error: PARSE syntax 91 {syntax error in expression " [HTTP::host] matches_glob "blah*.com" ": extra tokens at end of expression}] [{ [HTTP::host] matches_glob "blah*.com" }]
Basically I'm just trying to redirect a number of numbered domains (say blah1.com - blah10.com) to www.blah1.com without writing rules for each one.
Any thoughts?
- hooleylistCirrostratusThe iRule looks okay. It's odd that that you're getting an error. Are you on 10.0 or higher?
- dpeterson_24304NimbostratusSame error there. We're on 9.3.1.
A switch statement works though:
On https calls, detect no www and redirect to www
when HTTP_REQUEST {
switch -glob [HTTP::host] {"blah*.com" {HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"}}}
- hooleylistCirrostratusmatches_glob was added in 10.0.0. You could use switch -glob or string match in prior versions.
- dpeterson_24304NimbostratusAh, ok that makes sense, thanks! I did try string match and get a similar error, but switch works for this particular case.
Recent Discussions
Related Content
* 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