Forum Discussion
Edgar_Palamarch
Nimbostratus
Jun 14, 2012Redirect from non WWW to WWW host name
Hello,
I need a redirect from http://mySite.com to http://www.mySite.com The site is in ASP code, and developers couldn't do anything about the redirect. Is such a thing possible in iRule.
Thanks,
Edgar
5 Replies
- hoolio
Cirrostratus
Hi Edgar,
Here's an example you can use:when HTTP_REQUEST { if {[string tolower [HTTP::host]] ne "www.mysite.com"} { HTTP::redirect "http:://www.mysite.com[HTTP::uri]" } }
Aaron - Edgar_Palamarch
Nimbostratus
Thanks hoolio!
Is that the correct word: 'ne'? What does it mean?
Thanks again. I will be able to try this code a little later today and let you know if it works as expected. - Michael_Yates
Nimbostratus
Hi Edgar,
The "ne" is "not equal". You can also use an "!".
It can be expressed several different ways:
if {[string tolower [HTTP::host]] ne "www.mysite.com"} {
or
if {!([string tolower [HTTP::host]] ne "www.mysite.com")} {
or
if {[string tolower [HTTP::host]] != "www.mysite.com"} {
Hope this helps. - Edgar_Palamarch
Nimbostratus
Thanks, hoolio and Michael! The iRule works as expected. - Edgar_Palamarch
Nimbostratus
Actually, I overlooked the fact that we connect to www.mysite.com internally. Can I add an exception to the iRule so requests to www.mysite.mydomain.com go through?
Thank you for your time.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
