Forum Discussion
Heidi_35827
Nov 08, 2011Nimbostratus
iRule for HTTP redirect from retired URL to new URL
I'm new to iRules and could use some help. I think I have a pretty basic question but I'm not finding the answer after a few searches in DevCentral.
Here is what I'm trying to do....we have a web site that is retiring and will be replaced with a new site. We would like to do an http redirect to the new site when someone hits the old URL. Both sites are HTTPS. We want the URL in the users address bar to change to the new address.
Basic functionality: User goes to https://www.oldsite.com. Redirect is sent to send user to https://www.newsite.com
I've tried some basic HTTP redirect iRules, but none are working for me.
Do I need to use something other than a basic HTTP profile in the vserver I'm applying the iRule to?
Is the HTTPS adding some complexity that I'm not accounting for?
- Michael_YatesNimbostratusHi Heidi,
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.oldsite.com" } { HTTP::respond 301 Location "https://www.newsite.com" } } or when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.oldsite.com" } { HTTP::respond 301 Location "https://www.newsite.com[HTTP::uri]" } }
- natheCirrocumulusHeidi
- nitassEmployeeHTTP::redirect returns 302. if it is permanent, using 301 may be better.
[root@ve1023:Active] config b virtual bar list virtual bar { snat automap destination 172.28.65.152:https ip protocol tcp rules myrule profiles { clientssl { clientside } http {} tcp {} } } [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if {[string tolower [HTTP::host]] equals "www.oldsite.com"} { HTTP::redirect "https://www.newsite.com[HTTP::uri]" } } } [root@ve1023:Active] config curl -Ik https://www.oldsite.com HTTP/1.0 302 Found Location: https://www.newsite.com/ Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if {[string tolower [HTTP::host]] equals "www.oldsite.com"} { HTTP::respond 301 Location "https://www.newsite.com[HTTP::uri]" } } } [root@ve1023:Active] config curl -Ik https://www.oldsite.com HTTP/1.0 301 Moved Permanently Location: https://www.newsite.com/ Server: BigIP Connection: Keep-Alive Content-Length: 0
- Heidi_35827NimbostratusThank you all for your help! I'm going to give these a try today, I'll let you know what works or what option I go with.
- Heidi_35827NimbostratusWe are not doing SSL termination for this site. Could that be part of the issue? I realize we will get a cert error when using the old address, but the redirect should still work right?
- nitassEmployeeWe are not doing SSL termination for this site. Could that be part of the issue?ssl termination (clientssl profile) and http profile are needed since you need to parse http header and take an action accordingly.
- Heidi_35827NimbostratusOK, that makes sense. Thank you!
- eyambej72_11653Nimbostratusneed help with 301 redirect for this
- Kevin_StewartEmployeeTry this:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.old.com" } { HTTP::respond 301 Location "http://new.com[HTTP::uri]" } }
- eyambej72_11653Nimbostratussurvey-solutions left out ?
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