Forum Discussion
DM_5174
Nimbostratus
Feb 08, 2011HTTP REDIRECT AND KEEPING URI AFTER DOMAIN NAME
Hi All,
I was wondering if I can get a little help here. I have an existing irule that will redirect and add the "www" if
users forgets to put this in...so if they type "http://mysite....
hoolio
Cirrostratus
Feb 08, 2011George's iRule should definitely redirect requests with a hostname of mysite.com to www.mysite.com with the original path appended to the redirect. You might want to change [HTTP::path] to [HTTP::uri] to preserve any query string the client uses. If this isn't working for you, try adding debug logging to the iRule to see what the client is requesting. Note I've left off the else clause as the default will be to use the virtual server's default pool.
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]"
if { [HTTP::host] equals "mysite.com" } {
log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to http://www.mysite.com[HTTP::uri]"
HTTP::redirect "http://www.mysite.com[HTTP::uri]"
}
}
Aaron
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
