Forum Discussion
Leo
Mar 01, 2012Nimbostratus
Changing the URL
Hello friends,
I would like to add "www" to url's without it. meaning, if someone goes to "http://example.com/page.html" the F5 will redirect it to "http://www.example.com/page.html".
I've ...
Michael_Yates
Mar 02, 2012Nimbostratus
Hi Leonid,
I don't think that you need to bother checking to see if the [HTTP::host] is empty. If it is empty then it will never hit the Virtual Server. It could be an IP Address or something else but should never be empty.
This will do what you were wanting, but will not function properly if you hit the Virtual Server with an IP Address. If you want any traffic hitting the Virtual Server with an IP Address to respond properly you will need to add additional logic.
when HTTP_REQUEST {
if { !([HTTP::host] starts_with "www") } {
HTTP::respond 301 Location "http://www.[getfield [HTTP::host] ":" 1][HTTP::uri]"
}
}
Hope this helps.
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