Forum Discussion
ukitsysadmin_95
Nimbostratus
Jun 04, 2009redirect example.xx to www.example.xx
Hello
I'm new to irules, and would love some help on creating an irule for my problem below
Our web farm hosts a single domain name, but multiple geographic suffix's. e.g.
example.co.uk
example.be
example.fr
example.se
Now our back-end database will only accept www.example.xx (xx = country suffix)
So what we have to do is the following
DNS A records for
www point straight to our web farm (the database will accept www.example.xx)
But for anyone who uses the url, without www
example.co.uk
example.be
we have a standalone web server that redirects the url example.xx to www.example.xx for our site to work
I know irules can do this but I haven't a clue on where to start, this will improve performance and remove the single point of failure being the standalone web server
can anyone please help ????
many thanks in advance
- Colin_Walker_12Historic F5 AccountSo all you need to do is redirect anything that comes in without www to the www prepended version?
when HTTP_REQUEST { if { !([HTTP::host] starts_with "www.") } { HTTP::redirect "http://www.[HTTP::host][HTTP::uri]" } }
- ukitsysadmin_95
Nimbostratus
Hi Colin, - JRahm
Admin
This is domain independent, [HTTP::host] returns the domain that was submitted, and then just prepends www. to it. Now, if you're going to redirect to different domains/uri's based on source, welll that's a different story. Can you provide an example scenario? - ukitsysadmin_95
Nimbostratus
What i'm wanting to achieve, is the following - hoolio
Cirrostratus
If you only want to redirect domains which are listed in a datagroup, you could define them in a datagroup in lowercase and then use an iRule like this:when HTTP_REQUEST { Check if Host header is present with a length if {[string length [HTTP::host]]}{ Save host header value in lowercase set host [string tolower [HTTP::host]] Check if Host header does not start with www if {!($host starts_with "www.")}{ Check if host is listed in the domain datagroup if {[matchclass $host equals $::domains_to_redirect]}{ Redirect client to same URI but with www prepended to the host header value HTTP::redirect "http://www.[HTTP::host][HTTP::uri]" } } } }
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