Hille_de_Graaf_
Jan 31, 2008Nimbostratus
http to https 301 redirect based on uri content
I am looking for a way to the following.
If I only enter the host, for example http://www.mysite.com, I want to send it with a HTTP-301 to https://www.mysite.com/home
If I enter http://www.mysite.com/whatever_uri/, I want to redirect it with a HTTP-301 to https://[HTTP::host][HTTP::uri]
I made the following iRule
when HTTP_REQUEST {
if {[HTTP::uri] == ""}{
HTTP::respond 301 Location "https://www.mysite.com/home"
}
else {
HTTP::respond 301 Location "https://www.mysite.com[HTTP::uri]"
}
}
However when I check it with live headers and enter http://www.mysite.com, I only see a 301 redirect to https://www.mysite.com and not to https://www.mysite.com/home, what I would aspect.
Has anyone an idea what is wrong?
Hille