Forum Discussion
Heidi_35827
Nimbostratus
Nov 08, 2011iRule 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 ha...
nitass
Employee
Nov 09, 2011HTTP::redirect returns 302. if it is permanent, using 301 may be better.
What's the difference between 301 redirects and 302 redirects
http://webdesign.about.com/od/http/qt/tip301v302redir.htm
[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
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