Forum Discussion
Tyler_Jason_985
Nimbostratus
Aug 02, 2006Redirect HTTP to HTTPS Based upon URL
Hello all,
I am new to iRules, BigIP and the like so I apologize in advance.
I have a situation where I need to redirect HTTPs to HTTP when a url does not start with 'abc.xyz.com'. ...
Aug 02, 2006
The matchclass command is used to lookup values in a data group. This isn't needed since you are using a single string comparison on HTTP::host.
Second thing is that you need the HTTP::host value instead of the HTTP::uri. The format of the full url is:http://[HTTP::host][HTTP::uri]
http://abc.xyz.com/somepath
[HTTP::host] -> 'abc.xyz.com'
[HTTP::uri] -> '/somepath'
This should do it for you.
when HTTP_REQUEST {
if { ! [HTTP::host] equals "abc.xyz.com" } {
HTTP::redirect http://[HTTP::host][HTTP::uri]
}
}
(I changed "contains" to "equals" assuming that was the full domain name. If you truely want any domain containing your "abc.xyz.com" then leave the contains in there.)
Also, make sure that you don't have this rule processing on http or you could get into an infinite loop.
-Joe
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