Forum Discussion
Leo
Nimbostratus
Mar 01, 2012Changing 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 made the following iRule".
when HTTP_REQUEST {
if {[HTTP::host] ne ""} and {!{[HTTP::host] contains "www."}} {
HTTP::respond 301 Location "http://www.[getfield [HTTP::host]][HTTP::uri]"
}
}
I'm not so sure about the syntax, how does it look?
5 Replies
Sort By
- Michael_Yates
Nimbostratus
Hi Leonid,when HTTP_REQUEST { if { !([HTTP::host] starts_with "www") } { HTTP::respond 301 Location "http://www.[getfield [HTTP::host] ":" 1][HTTP::uri]" } }
- Leo
Nimbostratus
Thank's for the quick reply, - hoolio
Cirrostratus
You could use a browser plugin like Fiddler2 to check what redirects/references to http:// the browser is getting. - Leo
Nimbostratus
The certificate is fine.when HTTP_REQUEST { if { !([HTTP::host] starts_with "www") } { HTTP::respond 301 Location "https://www.[getfield [HTTP::host] ":" 1][HTTP::uri]" } }
- Leo
Nimbostratus
Apparently, it only happened on Firefox on my computer - other browsers and computers work well. Weird - but fine by me.
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