Forum Discussion
onlineops
Nimbostratus
May 01, 2018irule: root domain (only) non-www to www redirect
I have a series of websites that need a non-www to www redirect, bu I still need to support direct subdomains without a redirect.
Example:
http://abc.com redirects to http://www.abc.com http://...
onlineops
Nimbostratus
May 02, 2018That rule will work for the TLD (Top Level Domains) .com - and again, if I don't want to get specific about doing "OR" for all the possible TLDs, I think this works, regardless of top level domain:
when HTTP_REQUEST {
if { ([HTTP::host] matches_regex {^[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$}) } { HTTP::redirect http://www.[HTTP::host][HTTP::uri] }
}
when HTTP_REQUEST {
if { ([HTTP::host] matches_regex {^[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$}) } { HTTP::redirect https://www.[HTTP::host][HTTP::uri] }
}
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