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 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?
- Michael_YatesNimbostratusHi Leonid,
when HTTP_REQUEST { if { !([HTTP::host] starts_with "www") } { HTTP::respond 301 Location "http://www.[getfield [HTTP::host] ":" 1][HTTP::uri]" } }
- LeoNimbostratusThank's for the quick reply,
- hooleylistCirrostratusYou could use a browser plugin like Fiddler2 to check what redirects/references to http:// the browser is getting.
- LeoNimbostratusThe certificate is fine.
when HTTP_REQUEST { if { !([HTTP::host] starts_with "www") } { HTTP::respond 301 Location "https://www.[getfield [HTTP::host] ":" 1][HTTP::uri]" } }
- LeoNimbostratusApparently, 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