Forum Discussion
MikeM_44778
Nimbostratus
Jan 16, 2007Rewrite URL Context
How would I go about rewriting the following URL:
http://www.testsite.com/scripts/org.test.dispatch?app=uservariable
to go to
http://www.testsite.com/webapps/newsite/org.test.dispatch?app=uservariable
- JRahm
Admin
In its simplest form with no error-checking:when HTTP_REQUEST { HTTP::uri "/webapps/newsite/[findstr [HTTP::uri] "/scripts/" 9]" }
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/scripts/" } { HTTP::uri "/webapps/newsite/[findstr [string tolower [HTTP::uri]] "/scripts/" 9]" } }
- Another option would be to go with the "string map" command
when HTTP_REQUEST { HTTP::uri [string map -nocase {"/scripts/" "/webapps/newsite/"} [HTTP::uri]] }
- I didn't mean to point out that your approach wasn't clean. I just wanted to show a different alternative. Not every solution is right for each environment. My solution will cause odd behavior if the string "/scripts/" is embedded multiple places in the URI so in that case, your solution would work better as it replaces the first 9 characters. Sanity checks are always a good thing...
- JRahm
Admin
I wasn't offended in the least. I was glad to see an alternate solution to add to my archive. - MikeM_44778
Nimbostratus
Thanks! We are testing now, but that seems to be working.
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