Forum Discussion
Evaluate full URL for empty URI / Path ?
I need to deploy an iRule that will perform a redirect, based on the HTTP::uri or HTTP::path being empty. This needs to take into account a user trying 'http://server.company.com' and 'http://server.company.com/' and redirect based on the existence of ANY uri. That is... if the URI string is present, it will redirect to http://server.company2.com[HTTP::uri] and if the URI is NOT present (or is 'empty', even with no trailing 'slash' it should redirect to http://server.company3.com.
I seem to be getting caught in evaluating for an 'empty' URI, in the form of 'http://server.company.com/'
Any help or references ??
3 Replies
- Stephane_Viau
Nimbostratus
Randy, can you show what your iRule looks like? Only advice I have for now is to use HTTP::path for the condition because HTTP::uri also contains the query string so depending on how you built your condition, you might get unexpected results.
So I would do something like this (note that I added [HTTP::uri] in both redirects in case you need to keep the query string) :
if { ([HTTP::path] eq "" ) or ([HTTP::path] eq "/")} { HTTP::respond 301 Location http://server.company3.com[HTTP::uri] } else { HTTP::respond 301 Location http://server.company2.com[HTTP::uri] } - Root44
Altostratus
Is it something you want to try?
when HTTP_REQUEST { if { [HTTP::header host] eq "company.com" } or { [HTTP::header host] eq "company.com/" } { HTTP::redirect "http://server.company2.com[HTTP::uri]" }
else
{ HTTP::redirect "; } }
- Stanislas_Piro2
Cumulonimbus
Hi,
Browser never send empty uri in request.
The request format is :
GET /path HTTP/1.XOr (for some http 1.0 browser)
GET /pathThe uri is always at least /
When you do not enter any path in the browser, it append /
The code is
if {[HTTP::path] eq "/"} { HTTP::respond 301 Location http://server.company3.com/ } else { HTTP::respond 301 Location http://server.company2.com[HTTP::uri] }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
