switch command questions

Hi Guys,

I am trying to mimic a rule we currently have configured on our web servers.

RewriteCond %{REQUEST_URI} ^/view/.*\.do.*

RewriteCond %{REQUEST_URI} !^/view/secure/.*\.do.*

RewriteCond %{REQUEST_URI} !^/view/en_AU/secure/.*\.do.*

RewriteRule ^/(.*) ABC News & Headlines – Australian Broadcasting Corporation [R,L]

switch -glob [HTTP::uri] {

“/view/*.do*” {

HTTP::redirect “http://abc.com.au[HTTP::uri]”

}

“/view/secure/*.do.*” {}

“/view/en_AU/secure/*.do.*” {}

}

as far as order of operation goes the first entry matches the 2 below so should i put the most specific first and the least specific last?

If a match is made do the rest of the arguments get parsed?

also it is possible to use the not equals operator when using switch?

Only one switch case will be matched. You can add a default case if you want to catch any non-matches:

switch $some_string { 
    "case 1" { 
        case 1 action here 
    } 
    "case 2" { 
        case 2 action here 
    } 
    default { 
        default action here 
    } 
 }

If /view/*.do*" will match more generically, you should put it after the other cases. Not equals like logic isn’t possible, but again, you can use default to as a catch-all.

You can add logging to the switch cases to verify what’s happening.

Aaron

Thanks hoolio i figured it would work the same as use case statements but i wanted to be sure.