Forum Discussion
DDuck_139270
Nimbostratus
Jun 15, 2016HTTPS (old) to HTTPS (new) Redirect with an existing VS and Client Profile
I have read many postings on similar setups, but I am not sure any of them fit mine. So I need to share my scenario.
Here is the scenario:
I have an existing VS and a client profile that is termi...
Yann_Desmarest
Cirrus
Jun 15, 2016Ok, perfect, so using the below irule will help you redirect users coming to your app using an old hostname to the new hostname :
when HTTP_REQUEST {
if { !([HTTP::header "Host"] eq "newdomain.com") } {
HTTP::respond 301 Location "https://newdomain.com[HTTP::uri]" "Connection" "Close"
}
}
This irule will redirect every request made to a hostname different than newdomain. You can also define the opposite :
when HTTP_REQUEST {
if { [HTTP::header "Host"] eq "olddomain.com" } {
HTTP::respond 301 Location "https://newdomain.com[HTTP::uri]" "Connection" "Close"
}
}
And to conclude, if you have several old domains you want to include, you can use a string based datagroup with the below irule
when HTTP_REQUEST {
if { [class match [HTTP::header "Host"] equals DG_OLD_DOMAINS] } {
HTTP::respond 301 Location "https://newdomain.com[HTTP::uri]" "Connection" "Close"
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
