Forum Discussion
Ryan_McDonald_8
Nimbostratus
Aug 07, 2009Redirect to www
If a customer types in domainname.com I want them to be redirected to www.domainname.com.
I used the irule generator and came up with this
when HTTP_REQUEST {
if {[HTTP::uri] equals {http://scadalynx.com}} {HTTP::uri {http://www.scadalynx.com}
}
}
It doesn't seem to be working though. I have it applied to my port 80 virtual server. I also have a rule that then requires SSL and redirects them to https. The www rule is first. Ideally I would like one rule to do both, but any help making my www rule work is greatly appreciated.
TIA,
-Ryan
- A couple of points.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "scadalynx.com" } { HTTP::redirect "http://www.[HTTP::host][HTTP::uri]" } }
when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "scadalynx.com" } { if { [TCP::local_port] == 443 } { HTTP::redirect "https://www.[HTTP::host][HTTP::uri]" } else { HTTP::redirect "http://www.[HTTP::host][HTTP::uri]" } } }
- Ryan_McDonald_8
Nimbostratus
Hi Joe, - Ryan_McDonald_8
Nimbostratus
Couple of other pieces of information. - Ryan_McDonald_8
Nimbostratus
I was able to get the second rule to work with one minor change. (It wasn't redirecting http://www.scadalynx.com to https://www.scadalynx.com)
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