Forum Discussion
Pav_70755
Apr 01, 2011Nimbostratus
Host re-direct except for directory?
I've been trying to use this re-direct to re-direct a main domain e.g. www.oil.com to www.test.com/abc but I dont want www.oil.com/ger to re-direct
Here is what I've been trying to use but when I go to www.oil.com/ger its still re-directing
when HTTP_REQUEST {
Check if domain is "www.domain.com"
if {[string tolower [HTTP::host]] eq www.oil.com}{
Check if URI isn't /specialdirectory
switch [HTTP::uri] {
"/ger" {
Exit this event from this iRule
return
}
}
}
Redirect everything else to the following
HTTP::redirect "http://www.test.com/abc" }
- Joel_MosesNimbostratusTry this:
Update: Whoops. Shouldn't try typing fast before I've had my coffee. Missed a closed bracket and quotes.when HTTP_REQUEST { Check if domain is "www.domain.com" if {[string tolower [HTTP::host]] eq "www.oil.com"}{ Check if URI isn't /specialdirectory switch -glob [string tolower [HTTP::uri]] { "/ger" - "/ger/" - "/ger/*" { Exit this event from this iRule return } default { Redirect everything else to the following HTTP::redirect "http://www.test.com/abc" } } } }
- Pav_70755NimbostratusThanks Joel am getting the following error
- JRahmAdminPut www.oil.com in quotes. And you don't need the string tolower on HTTP::host.
- Joel_MosesNimbostratusI've updated the rule above.
- dlg_23340CirrusI think you've still got an extra ] here:
if {[string tolower [HTTP::host]] eq "www.oil.com"]}{
- Pav_70755NimbostratusMany thanks Joel I've just tested the irule and it works perfectly thanks again for your help.
- Joel_MosesNimbostratus
Absolutely -- good to hear it's working for you; glad to help.
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