Forum Discussion
Kate_Kattar_107
Nimbostratus
Jul 22, 2008URL forwarding help
I have a fairly simple request but need some guidance regarding the best way to do it. My client is lauching a new website and would like to forwarding 30 other urls to this new url. For instance:
www.site1.com should be forwarded to www.newsite.com/site1
www.site2.com should be forwarded to www.newsite.com/site2
Should I be using irules to do this?
What syntax should I use? Something like this:
when HTTP_REQUEST {
if { [HTTP::host] equals {www.prioryhospital.com} and [HTTP::uri] equals "/"} {HTTP::redirect "http://bbc.co.uk"
}
return
}
This incidently doesn't work and I imagine its a little messy.
Cheers
Kate
- The_Bhattman
Nimbostratus
Hi Kate,when HTTP_REQUEST { switch -glob [HTTP::host] { "www.site1.com" { HTTP::redirect "http://www.newsite.com/site1" } "www.site2.com" { HTTP::redirect "http://www.newsite.com/site2" } "www.site3.com" { HTTP::redirect "http://www.newsite.com/site3" } "www.siteN.com" { HTTP::redirect "http://www.newsite.com/siteN" } . . . } }
- Kate_Kattar_107
Nimbostratus
Thank You. Works perfectly and its so simple. - Kate_Kattar_107
Nimbostratus
I have now been asked to make further additions to the rule. The following does not work. Do I need to use a different value other than [HTTP::host]? - Andy_Herrman_22
Nimbostratus
HTTP::host only gives you the hostname (host.co.uk). HTTP::uri will give you the path (/about.cfm), so try:when HTTP_REQUEST { switch -glob "[HTTP::host][HTTP::uri]" { "host.co.uk/about.cfm" { HTTP::redirect "http://www.newhost.co.uk/page1 " } "host.co.uk/audit.cfm" { HTTP::redirect "http://www.newhost.co.uk/aboutpage " } } }
when HTTP_REQUEST { switch -glob [string tolower "[HTTP::host][HTTP::uri]"] { "host.co.uk/about.cfm" { HTTP::redirect "http://www.newhost.co.uk/page1 " } "host.co.uk/audit.cfm" { HTTP::redirect "http://www.newhost.co.uk/aboutpage " } } }
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