Forum Discussion
John_LeMay_1062
Nimbostratus
Dec 19, 2005Another uri rewrite question
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.
2 Replies
Sort By
- I don't see any reason why your rule wouldn't work, but there is a bunch of extra code that you really don't need to be running.
when HTTP_REQUEST { HTTP::redirect "https://[HTTP::host][HTTP::uri]" }
when HTTP_REQUEST { if { [string length [HTTP::uri]] <= 1 } { HTTP::uri "/string" } }
- John_LeMay_1062
Nimbostratus
In rereading my original post, it looks like I was a bit ahead of myself.
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