Forum Discussion
DaveC_21078
Altostratus
Dec 10, 2010http redirect to sub-domain
I need to do a simple redirect for any requests coming in to http://domainname.com, https://domainname.com, http://www.domainname.com or https://www.domainname.com to https://sub.domainname.com. What should it look like?
Thanks
2 Replies
- hoolio
Cirrostratus
Hi Dave,
I suggest configuring a separate virtual server for HTTP and one for HTTPS. If you add a client SSL profile, you can redirect client requests to non-sub.domainname.com hosts using the same iRule as shown below. Or if you wanted to use separate iRules for HTTP and HTTPS, you could simplify the iRules and remove the CLIENT_ACCEPTED event and hard code the protocol to http:// or https://.when CLIENT_ACCEPTED { Check the client's destination port switch [TCP::local_port] { 443 { Request is to an SSL port set proto "https" } default { Request is to a non-SSL port set proto "http" } } } when HTTP_REQUEST { Check if host isn't sub.domainname.com if {[string tolower [HTTP::host]] ne "sub.domainname.com"}{ Redirect to the same protocol and URI to the correct hostname HTTP::redirect "${proto}://sub.domainname.com[HTTP::uri]" } }
Aaron - DaveC_21078
Altostratus
Thanks. I'll give that a try. I would never have come up with this solution.
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