Forum Discussion
Irule redirection from old URL (abc.com) to new URL (xyz.com)
All,
Looking for irule to redirect when user hits abc.com that should redirect to xyz.com. Note: xyz.com is just a CNAME for abc.com.
looking forward for your help.
Thanks, TS
- Yann_Desmarest_
Nacreous
Hi,
You can use the following irule :
when HTTP_REQUEST { if { [HTTP::host] eq "abc.com" } { HTTP::respond 302 noserver Location "http://xyz.com" Connection Close alternative : HTTP::redirect "http://xyz.com" } }
Or you may prefer to use an LTM policy for that.
Yann
- tsm_329805
Nimbostratus
Thanks for quick reply.
Sorry about my ask, forgot to mention that the requirement is for https. will this below still valid.? //
when HTTP_REQUEST { if { [HTTP::host] eq "abc.com" } { HTTP::redirect "; } }
//
Thanks, TS
- Yann_Desmarest_
Nacreous
Yes sure. it's still valid.
I prefer using
but you can also useHTTP::respond
. I prefer the first option because you have more control on the response like removing Server header, Closing connection, etc.HTTP::redirect
Hi,
You can use the following irule :
when HTTP_REQUEST { if { [HTTP::host] eq "abc.com" } { HTTP::respond 302 noserver Location "http://xyz.com" Connection Close alternative : HTTP::redirect "http://xyz.com" } }
Or you may prefer to use an LTM policy for that.
Yann
- tsm_329805
Nimbostratus
Thanks for quick reply.
Sorry about my ask, forgot to mention that the requirement is for https. will this below still valid.? //
when HTTP_REQUEST { if { [HTTP::host] eq "abc.com" } { HTTP::redirect "; } }
//
Thanks, TS
Yes sure. it's still valid.
I prefer using
but you can also useHTTP::respond
. I prefer the first option because you have more control on the response like removing Server header, Closing connection, etc.HTTP::redirect
- Jad_Tabbara__J1
Cirrostratus
Hello tsm,
you can also use it to https 😉 add the "string tolower" so you can also redirect hostname with capital letter (example ABC.com).
when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "abc.com" } { HTTP::respond 302 noserver Location "https://xyz.com" Connection Close alternative : HTTP::redirect "https://xyz.com" } }
Regards
Recent Discussions
Related Content
* 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