Forum Discussion
Brad_146558
Nimbostratus
Mar 20, 2015Trouble with redirect
I'm trying to write a redirect from the root level of a domain(ex domain.com), to www.domain.com. I know the best and easiest way would be to just put a redirect on the web server, but as sane as tha...
Hannes_Rapp
Nimbostratus
Mar 20, 2015Notice the error with "http://" string in your host equals statement? Protocol is not part of the HTTP host header 🙂
when HTTP_REQUEST {
if { [HTTP::host] equals "domain.com" }
{ HTTP::redirect "http://www.domain.com" }
}
A more universal solution for the missing www. problem is below (a single iRule can be used repeatedly for multiple applications):
when HTTP_REQUEST {
if { not([HTTP::host] starts_with "www.") } {
HTTP::respond 302 location "http://www.[HTTP::host][HTTP::uri]"
event disable
TCP::close
}
}
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