I’m trying to write a simple iRule to check for a blank uri and replace it with “/string”. It is possible there would be valid uri’s passed (/string2 for example), so I only want to add “/string” if there is no current uri specified.
Here is what I have:
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri eq “” }{ set uri “/string” }
if { $uri eq “/”}{ set uri “/string” }
HTTP::uri $uri
}
I’ve tried a few iterations, but everything I seem to try results in “/string” being appended to every client request (for example, a request for http://server/string2 becomes http://server/string2/string).
This rule is on a VS listening on port 443. There is a second server listening on port 80 with a similar rule meant to fix the uri and redirect the client to the 443 VS:
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri eq “” }{ set uri “/string” }
if { $uri eq “/”}{ set uri “/string” }
HTTP::uri $uri
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
I don’t believe having both rules in place is causing the issue. The point of having both though is to catch and fix users who may access the site via http as well as those who may try to access the site directly via https.