Forum Discussion
Rewrite certain URI content
Hello,
I have an existing iRule to rewrite a URI so it rewrites to something. I need to rewrite/omit a certain syntax and leave all else the same. For an example:
The existing iRule is to drop out '/Today' and rewrite it https://mycompany.com/Firstpage/Today/Monday/main -> should rewrite to https://mycompany.com/Firstpage/Monday/main
What I'm looking for is to still have the same effect, but if the client enters anything after /main/1/2/3 it should rewrite it as: /Firstpage/Monday/main/1/2/3. The problem is that there are so many variance after /main that the client can type in. We want the rewrite to include whatever the client types in after /main. How can I add to this existing iRule to make something like that work?
Here is my current iRule:
Code
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/Firstpage/Today/Monday/main"} {
HTTP::uri "/Firstpage/Monday/main" 1 Reply
- Kevin_Stewart
Employee
So is it a specific word, like "Today" that you need to remove, or a specific part of the URI, like the second field in the path?
If the former, then a string map would probably work.
when HTTP_REQUEST { if { [string tolower [HTTP::URI]] contains "/today" } { set URI [string map -nocase {"/today" ""} [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