Forum Discussion
pkhatri_72515
Nimbostratus
Jan 15, 2010need 301 redirect help please.
301 redirect of following. Can you please help me out on a best way to do this in F5? iRule? version 9.3.
http://www.bla.com/home/index.cfm?&LANG=EN&CountryLanguage=EN_GL -------> http://www.bla.com/gl
http://www.bla.com/home/index.cfm?&LANG=EN&CountryLanguage=EN_AP-------> http://www.bla.com/ap
http://www.bla.com/home/index.cfm?&LANG=FR&CountryLanguage=FR-------> http://www.bla.com/fr
http://www.bla.com/home/index.cfm?&LANG=DE&CountryLanguage=DE-------> http://www.bla.com/de
http://www.bla.com/home/index.cfm?&LANG=EN&CountryLanguage=EN_IR-------> http://www.bla.com/ie
http://www.bla.com/home/index.cfm?&LANG=IT&CountryLanguage=IT-------> http://www.bla.com/it
http://www.bla.com/home/index.cfm?&LANG=NL&CountryLanguage=NL-------> http://www.bla.com/nl
http://www.bla.com/home/index.cfm?&LANG=PR&CountryLanguage=PR-------> http://www.bla.com/pr
http://www.bla.com/home/index.cfm?&LANG=SP&CountryLanguage=SP-------> http://www.bla.com/es
http://www.bla.com/home/index.cfm?&LANG=SW&CountryLanguage=SW-------> http://www.bla.com/se
http://www.bla.com/home/index.cfm?&LANG=EN&CountryLanguage=EN_UK-------> http://www.bla.com/uk
Thanks,
7 Replies
- naladar_65658
Altostratus
I am not certain how elegant this is and I haven't had a chance to test it out, but this should get you going in the right direction:when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri] ] { "*countrylanguage=en_gl*" { HTTP::respond 301 Location http://www.bla.com/gl } "*countrylanguage=en_ap*" { HTTP::respond 301 Location http://www.bla.com/ap } "*countrylanguage=fr*" { HTTP::respond 301 Location http://www.bla.com/fr } "*countrylanguage=de*" { HTTP::respond 301 Location http://www.bla.com/de } "*countrylanguage=en_ir*" { HTTP::respond 301 Location http://www.bla.com/ie } "*countrylanguage=it*" { HTTP::respond 301 Location http://www.bla.com/it } "*countrylanguage=nl*" { HTTP::respond 301 Location http://www.bla.com/nl } "*countrylanguage=pr*" { HTTP::respond 301 Location http://www.bla.com/pr } "*countrylanguage=sp*" { HTTP::respond 301 Location http://www.bla.com/es } "*countrylanguage=sw*" { HTTP::respond 301 Location http://www.bla.com/se } "*countrylanguage=en_uk*" { HTTP::respond 301 Location http://www.bla.com/uk } } }
- The_Bhattman
Nimbostratus
Here is a another way to do this. It hasn't been tested but it's a bit more refined.when HTTP_REQUEST { switch -glob [string tolower [uri::query [HTTP::uri] CountryLanguage]] { "en_gl" { HTTP::respond 301 Location "[HTTP::host]/gl" } "en_ap" { HTTP::respond 301 Location "[HTTP::host]/ap" } "fr" { HTTP::respond 301 Location "[HTTP::host]/fr" } "de" { HTTP::respond 301 Location "[HTTP::host]/de" } "en_ir" { HTTP::respond 301 Location "[HTTP::host]/ie" } "it" { HTTP::respond 301 Location "[HTTP::host]/it" } "nl" { HTTP::respond 301 Location "[HTTP::host]/nl" } "pr" { HTTP::respond 301 Location "[HTTP::host]/pr" } "sp" { HTTP::respond 301 Location "[HTTP::host]/es" } "sw" { HTTP::respond 301 Location "[HTTP::host]/se" } "en_uk" { HTTP::respond 301 Location "[HTTP::host]/uk" } Default { HTTP::respond 301 Location "[HTTP::host]/nosite.html" } } }
- pkhatri_72515
Nimbostratus
Thank you guys! appreciate your time here. - hoolio
Cirrostratus
Nice ones... - Brandon_83145
Nimbostratus
Related question. Can someone help combine a redirect rule that looks for both the host and uri (everything after the /)? - hoolio
Cirrostratus
Hi Brandon,when HTTP_REQUEST { switch -glob "[string tolower [HTTP::host]][HTTP::path]" { "*sample.com/folder1*" {HTTP::redirect "http://site.sample.com/default.aspx"} "*test.com/*" {HTTP::redirect "https://site.test.com/Pages/home.aspx"} default {HTTP::redirect "https://www.test.com"} } }
- pkhatri_72515
Nimbostratus
Great! Guys, Awesome help,,, Thanks!!
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