Forum Discussion
rmangram07_7795
Nimbostratus
Jul 26, 2013Redirecting Old Site to New Site Same Directory
I am new to irules and this seems straight forward but I cannot find the answer to this:
I have a site www.oldsite.com redirected to www.landingpage.com, and that works fine.
...
nitass
Employee
Aug 07, 2013for http://www.oldsite.com/it it does not work i thought you want "/it/useradmin/*". if it is "/it/*", you can just change from "/it/useradmin/" to "/it/" in the irule.
if they go to https://ww.oldsite.com they stay at oldsite.com. I need them to go to landingpage.com as well. i understand you have 2 virtual servers; one is 80 and the other one is 443, haven't you? what irule do you apply to 443 virtual server?
e.g.
[root@ve10:Active] config b virtual bar80 list
virtual bar80 {
snat automap
pool foo
destination 172.28.19.252:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
[root@ve10:Active] config b virtual bar443 list
virtual bar443 {
snat automap
pool foo
destination 172.28.19.252:443
ip protocol 6
rules myrule
profiles {
clientssl {
clientside
}
http {}
tcp {}
}
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "oldsite.com" } {
set uri [string tolower [HTTP::uri]]
if { $uri equals "/" } {
HTTP::respond 302 noserver Location "https://landingpage.com"
} elseif { not ($uri starts_with "/it/") } {
HTTP::respond 302 noserver Location "https://newsite.com[HTTP::uri]"
}
}
}
}
http
[root@ve10:Active] config curl -I http://172.28.19.252/ -H "Host: oldsite.com"
HTTP/1.0 302 Found
Location: https://landingpage.com
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -I http://172.28.19.252/something -H "Host: oldsite.com"
HTTP/1.0 302 Found
Location: https://newsite.com/something
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -I http://172.28.19.252/it/something -H "Host: oldsite.com"
HTTP/1.1 404 Not Found
Date: Thu, 08 Aug 2013 01:47:16 GMT
Server: Apache/2.2.3 (CentOS)
Content-Type: text/html; charset=iso-8859-1
https
[root@ve10:Active] config curl -Ik https://172.28.19.252/ -H "Host: oldsite.com"
HTTP/1.0 302 Found
Location: https://landingpage.com
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -Ik https://172.28.19.252/something -H "Host: oldsite.com"
HTTP/1.0 302 Found
Location: https://newsite.com/something
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -Ik https://172.28.19.252/it/something -H "Host: oldsite.com"
HTTP/1.1 404 Not Found
Date: Thu, 08 Aug 2013 01:47:33 GMT
Server: Apache/2.2.3 (CentOS)
Content-Type: text/html; charset=iso-8859-1
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