Forum Discussion
Redirect non www and https issue
The 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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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