Forum Discussion
DaveC_21078
Dec 10, 2010Altostratus
http 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
- hooleylistCirrostratusHi Dave,
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]" } }
- DaveC_21078AltostratusThanks. I'll give that a try. I would never have come up with this solution.
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