Forum Discussion
DaveC_21078
Altostratus
Aug 23, 2010Remove www before passing request to web server
Because of a licensing issue, we have to strip www. from the URL before passing it to the web server, if the user typed in www. So a request to www.mypage.com/blah/blah2... should get re-written mypage.com/blah/blah2.... I tried a simple redirect, when HTTP_REQUEST { HTTP::redirect ] }, but that didn't work at all. I think I can see why it wouldn't work, but not sure how to do it. Thanks in advance.
2 Replies
- Moe_Jartin
Cirrus
Dave,
You have to add an if statement to determine when you want to redirect. Otherwise, as it is written, you are redirecting EVERY request so the browser gets stuck in an infinite redirect. Install a header plugin in your browser (like LiveHTTPHeaders for Firefox) and watch the headers and you'll see what I mean. Try this.when HTTP_REQUEST { if { [HTTP::host] equals "www.mypage.com" }{ HTTP::redirect http://mypage.com[HTTP::uri] } } <\code> Joe Martin - DaveC_21078
Altostratus
Thanks Joe. That fixed it.
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www."} {
HTTP::redirect ]
}
}
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
