Forum Discussion
Chris_Robert_10
Nimbostratus
Sep 15, 2006URL rewrite plus
I currently have this iRule running:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/www.mysite.com/" } {
HTTP::uri "/www.mysite.com/index.htm/"
}
}
They now want me to force the addition of www if the enduser does not enter it. How can I do this without getting www.www.mysite.com/index.htm/?
Sorry for a noob question, but I rarely am in this system.
- Deb_Allen_18Historic F5 AccountURL's take the form of:
HTHwhen HTTP_REQUEST { if {[string tolower [HTTP::host] equals "mysite.com" } { HTTP::header replace Host "www.mysite.com" HTTP::uri "/index.htm" } }
- Deb_Allen_18Historic F5 AccountActually, this makes more sense for the URI replacement:
when HTTP_REQUEST { if {[string tolower [HTTP::host] equals "mysite.com" } { HTTP::header replace Host "www.mysite.com" } if {[string length [HTTP::uri]] <= 1 } { HTTP::uri "/index.htm" } }
- unRuleY_95363Historic F5 AccountI think he may actually want a redirect, so the users browser actually get's updated to include the www.
- Eric_Grepps_264
Nimbostratus
I am stumbling with the same issue. I need to add "www" only if the person did not enter it as the host.when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::redirect https://[HTTP::host]/login.do } else { HTTP::redirect https://[HTTP::host][HTTP::uri] } }
- Eric_Grepps_264
Nimbostratus
I got it to work using the following iRule:when HTTP_REQUEST { set sHost "[getfield [string tolower [HTTP::host]] "." 3]" if { [HTTP::host] starts_with "www" }{ HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } elseif {[string length $sHost] == 0 }{ HTTP::redirect https://www.[getfield [HTTP::host] ":" 1][HTTP::uri] } else { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } }
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