Forum Discussion
Govin_48123
Nimbostratus
May 12, 2008Masking the URI and also redirecting!
Hi Gurus,
Below is the scenarios I am trying to implement, and need some help,
Case 1)User Types in http://www.site.com/, the application server basically does a 301 redirect to http://www.site.com/home. What I am trying to implement is instead of the appserver doing the redirect I want to handle that at the F5,
http://www.site.com/ should be redirected to http://www.site.com/home with 200 response code and the address bar should show http://www.site.com/
Case 2)User Types in http://www.site.com, I want to redirect to http://www.site.com/ with 301 response code which then follows through case1).
Case 3) User types in http://www.site.com/home then the Client gets response directly form the appserver, Irule doesnt need to handle this at all.
Below is the Irule that I have but its not perfect,The Uri doesnt get masked)Can you tell me what I am missing!
Thanks
-G
Irule:
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri equals "/" } {
HTTP::respond 301 Location "http://site.com/home"
}
elseif { $uri equals "" } {
HTTP::respond 200 Location "http://site.com/"
}
}
- hoolio
Cirrostratus
A few comments:when HTTP_REQUEST { if {[HTTP::path] eq "/"}{ HTTP::respond 301 Location "http://site.com/home" } }
- How about this?
when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::uri "/home" } }
- Govin_48123
Nimbostratus
Thanks Joe and Hoolio for the replies! I understand now that the browser appends a / even when the URI is "". - My solution is not a redirect. It changes the URI on the LTM before it gets to your app server. The browser requested "/", the LTM changed it to "/home" and the webserver received it as "/home". Everyone is happy!
- Govin_48123
Nimbostratus
Thanks Joe. That works perfect! U guys Rock! - Glad to help!
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