Forum Discussion
Glenn_Ruffus_10
Nimbostratus
Dec 18, 2007Force "www." redirect if missing from HTTPS requests
I am looking for help in writing an iRule that will be used on an HTTPS virtual server. I would like the LTM to examine the HTTP request and if the URL does not include "www." then redirect the browser to come back to the same URL/URI as found in the original request, only with www. put on the front of the URL. I am doing this so that the requested URL will always match the URL on the digital certificate. I'd like the iRule to be generic so that it can be applied to any virtual server regarding any URL/URI.
Example:
If an HTTP(S) request comes in for fred.flintstone.com/pebbles/dino...
then redirect the browser to come back as: https://www.fred.flintstone.com/pebbles/dino...
If the HTTP(S) request comes in for www.fred.flintstone.com/pebbles/dino... then don't take any further action because the requested URL matches the URL on the digital certificate.
Thanks.
Glenn
- Colin_Walker_12Historic F5 AccountFor this kind of a rule all you'd need is something like:
when HTTP_REQUEST { if { ! ( [HTTP::host] starts_with "www." ) } { HTTP::redirect "https://www.[HTTP::host][HTTP::uri]" } }
- Glenn_Ruffus_10
Nimbostratus
Thanks, Colin. I have not had the time (obviously) to learn about the iRules so I have no skill. Sorry if this question is a stupid one. - hoolio
Cirrostratus
Hi Glenn, - Glenn_Ruffus_10
Nimbostratus
Thanks, Aaron. - Colin_Walker_12Historic F5 AccountAhh, I was a little concerned this is the turn this thread would take. :-/
- Glenn_Ruffus_10
Nimbostratus
-Very good, Colin. Thanks for the explanation and all of the help.
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