Forum Discussion
Bob_10976
Jan 23, 2012Nimbostratus
Limiting WWW redirect to just WWW
Hello all...
We have an irule in place that redirects www.domain.com to non domain.com version. This seems to work fine with one exception. If the end user goes to www.domain.com/blog then they are redirected back to the home site of domain.com. What I'd like to do is when someone goes to www.domain.com/blog (or / whatever) that the www remains in place, but if they go to the root of the site, www.domain.com that they end up at domain.com.
Below is the what we currently use, any suggestions on how I can modifiy this?
www.domain.com {
HTTP::respond 301 Location http://domain.com
}
Thanks,
Bob
- Colin_Walker_12Historic F5 AccountIt sounds like you're looking for is for the redirect to include the URI, which is something we've seen many times using the redirect command, and would change very little in your case using the respond command:
when HTTP_REQUEST { if { [HTTP::host] eq "www.domain.com"} { HTTP::respond 301 Location "http://domain.com[HTTP::uri]" } }
- Bob_10976NimbostratusColin,Thanks! That sounds like what I want to do excatly. However I do have one follow up question. We host a lot of sites and I'm using an irule format that I'm not sure how I could incorporate your syntax into the current rulle. Below is an example of the rule we have in place..
when HTTP_REQUEST { switch "[string tolower [HTTP::host]]" { "domain1.com" - www.domain1.com { HTTP::respond 301 Location http://domainName.com } "domain2.com" - www.domain2.com { HTTP::respond 301 Location https://domain2.com } www.domain.com { HTTP::respond 301 Location "http://domain.com/" } "domain3.com" { HTTP::respond 301 Location "https://domain3.com/" } "domain4.com" { if {[string tolower [HTTP::uri]] eq "/aer/"}{ HTTP::respond 301 Location "http://domain4.com/artsdirectory.aspx" } ETC.. ETC.. ETC..
- Bob_10976NimbostratusThanks Colin.. After a few trails I got it figured out, not as hard as I thought it would have been..
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