Forum Discussion
HTTPS Redirect to append www
Hi, I'm a fairly new to iRules, so am requesting some assistance. We have a domain: cardiosmart.org. We have 2 LB VS objects (http and https). We have iRules for both objects. The behavior when people type: cardiosmart.org into their browser is correct, it redirects to https://www.cardiosmart.org. However, if folks type: https://cardiosmart.org the "www" does not get appended. We want the "www" to be appended regardless of of what folks type. Below are the iRules I have for both objects and I'm not entirely sure what it all means, but the site is working as needed, other than the www redirect for https to include www.
Do I only need to modify the iRule on the HTTPS object to append an "s" to the "http" in this part: equals "http://cardiosmart.org" }?
Appreciate any assistance you all can provide!
Diane
iRule Associated w/HTTP object:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] contains "/Videos.aspx" } {
if {[active_members Cardiosmart_HTTP] > 0} {
pool Cardiosmart_HTTP
} else {HTTP::redirect "http://maintenance.acc.org"
event disable all
}
}
else { HTTP::respond 301 Location https://www.cardiosmart.org[HTTP::uri]
}
}
iRule Associated w/HTTPS object:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "healthandwellness.cardiosmart.org" } {
HTTP::redirect "https://www.cardiosmart.org[HTTP::uri]"
}
if { [string tolower [HTTP::host]] equals "http://cardiosmart.org" } {
HTTP::redirect "https://www.cardiosmart.org"
}
}
2 Replies
- nitass
Employee
Are you saying just stripping off the "http" after "equals" will properly redirect the HTTPS requests to ""?
HTTP::host does not contain protocol. it is host header e.g. cardiosmart.org.
And this is the iRule associated with our HTTPS object is where I should do this?
yes, it is assigned to https virtual server. i understand http virtual server's irule has no issue, hasn't it?
- dlogsdonmd
Nimbostratus
Thanks much for the answer and the explanation. That worked perfectly. Happy Holidays!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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