Forum Discussion
DScottSLC_13452
Nimbostratus
Jan 06, 2015Redirect non www and https issue
Hi,
We have two Irules on a Virtual Server pool that seem to be causing an intermittent issue for some clients / browsers.
_sys_https_redirect (the default F5 one included on the BIGIP boxes) an...
Michael_Jenkins
Cirrostratus
Jan 06, 2015The best way that I've found to do this is using the
event command More info here.
Because you can't have multiple redirects, you would either need to set a flag to say a redirect has already occurred and check it later (which obviously wouldn't work for the built-in rule). Otherwise, you could use the event command. I would say you could change the Location header in the HTTP_RESPONSE event, but I don't think that gets executed when you do a redirect from an iRule.
So, my suggestion would be something like this:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "pennyforlondon.com" } {
Disable further events for this connection
event disable all
Redirect the user. Make sure to add the Connection Close header because the event command is set per connection. So we need a new connection in order for the rules to execute again.
HTTP::respond 301 Location "***REPLACE***[HTTP::uri]" "Connection" "Close"
}
}
NOTE: Replace
***REPLACE*** with https://www.pennyforlondon.com. The editor messes up URLs when posting, so just replace it in your iRule and you should be good.
Hope this helps.
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