Forum Discussion
adam21983_1462
Nimbostratus
Jan 18, 2013Simple URL Redirect Question
Hello Everyone,
Sorry if this is overly simple but I am driving myself crazy trying to get this to work. In the below iRule my redirect works if the request is sent to http://redirecttest.mysite.com but does not work if the request is sent to http://www.redirecttest.mysite.com
How can i get this to work if "www" is part of the HOST?! Thanks to everyone! -Adam
when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] equals "redirecttest.mysite.com") } {
HTTP::redirect http://google.com
}
if { ([string tolower [HTTP::host]] equals "www.redirecttest.mysite.com") } {
HTTP::redirect http://google.com
}
6 Replies
- s3s1277_111291
Nimbostratus
Instead of 'equals' use 'contains' - What_Lies_Bene1
Cirrostratus
Try this;when HTTP_REQUEST { if { (([string tolower [HTTP::host]] equals "redirecttest.mysite.com") or ([string tolower [HTTP::host]] equals "www.redirecttest.mysite.com"))} { HTTP::redirect "http://google.com" return } } - adam21983_1462
Nimbostratus
Hi Guys, Unfortunetly neither of these options are working for me. Any ideas? Thanks! -Adam - adam21983_1462
Nimbostratus
Hi Guys, Unfortunetly neither of these options are working for me. Any ideas? Thanks! -Adam - nitass
Employee
doesn't your original irule work??[root@ve10:Active] config b virtual bar list virtual bar { destination 172.28.19.252:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if { ([string tolower [HTTP::host]] equals "redirecttest.mysite.com") } { HTTP::redirect http://google.com } if { ([string tolower [HTTP::host]] equals "www.redirecttest.mysite.com") } { HTTP::redirect http://google.com } } } [root@ve10:Active] config curl -I http://redirecttest.mysite.com HTTP/1.0 302 Found Location: http://google.com Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@ve10:Active] config curl -I http://www.redirecttest.mysite.com HTTP/1.0 302 Found Location: http://google.com Server: BigIP Connection: Keep-Alive Content-Length: 0 - Jnon
Nimbostratus
As mentioned above - it should work if you eliminate the www and change to contains as follows
when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] contains "redirecttest.mysite.com") } {
HTTP::redirect http://google.com
}
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