Forum Discussion
theizer_91634
Nimbostratus
Apr 01, 2009multiple redirects - newb needs help
ok...trying my hand at iRules
we own domain.com and domain.net
I need my rule to redirect the following:
1. http://domain.com to https://www.domain.com
2. http://domain.net to https://www.domain.com
3. http://[anything].domain.net to https://www.domain.com
4. http://[anything not "www"].domain.com to https://www.domain.com
5. http://www.domain.com/[path] to https://www.domain.com/[path]
Here is what I have so far. I know I am missing a lot and would really appreciate any help you guys can give.
when HTTP_REQUEST {
if {[HTTP::uri] equals {http://domain.com}} {HTTP::redirect https://www.domain.com
}
elseif {[HTTP::request] contains "domain.net"} {HTTP::redirect https://www.domain.com
}
else
{HTTP::redirect https://[HTTP::host][HTTP::uri]}
}
- dennypayne
Employee
Hi,when HTTP_REQUEST { if { not [HTTP::host] equals "www.domain.com" }{ HTTP::redirect "https://www.domain.com" } else { HTTP::redirect "https://www.domain.com/[HTTP::uri]" } }
- theizer_91634
Nimbostratus
Thanks for the reply! - hoolio
Cirrostratus
Try wrapping the condition you're NOT'ing in parentheses:when HTTP_REQUEST { if { not ([string tolower [HTTP::host]] equals "www.domain.com") }{ HTTP::redirect https://www.domain.com } else { HTTP::redirect "https://[HTTP:host][HTTP::uri]" } }
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.domain.com" }{ HTTP::redirect https://[HTTP:host][HTTP::uri] } else { HTTP::redirect "https://www.domain.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