Forum Discussion
Lolo_17756
Nimbostratus
Feb 08, 2010iRule Rewrit URI
Hello i' m has newbee in BigIp world.
I need to modify an URI in the following way:
URi Users = https://hostname/(S(session number))/blabla/blabla.xxx
It is possible to rewrite this URI with iRules like these:
https://hostname/blabla/blabla.xxx
Verry thanks for your help
Laurent
- The_Bhattman
Nimbostratus
Hi Lolo,when HTTP_REQUEST { if { [HTTP::host] eq "hostname")} { HTTP::redirect "https://[HTTP::host][URI::path [HTTP::uri] 2][URI::basename [HTTP::uri]]" } }
- Lolo_17756
Nimbostratus
- The_Bhattman
Nimbostratus
Post up your results when you have confirmed whether it has worked or not. - hoolio
Cirrostratus
Another option for removing the first string between forward slashes is to use scan (Click hereüòûwhen HTTP_REQUEST { Read in everything after the first / that is not a /. Save that to $session_id and everything else to $uri_to_save scan [HTTP::uri] {/%[^/]%s} session_id uri_to_save Rewrite the URI without the session ID HTTP::uri $uri_to_save }
- Lolo_17756
Nimbostratus
It's OK and i have add filter on file extention: - hoolio
Cirrostratus
It would be more efficient to use switch and string comparisons to check the object type versus a regex. Here is an example:when HTTP_REQUEST { Check the requested path (URI minus query string) switch -glob [string tolower [HTTP::path]] { "*.gif" - "*.js" - "*.css" - "*.jpg" - "*.bmp" { Read in everything after the first / that is not a /. Save that to $session_id and everything else to $uri_to_save scan will return the number of matches if {[scan [HTTP::uri] {/%[^/]%s} session_id uri_to_save] == 2}{ Rewrite the URI without the session ID log local0. "$session_id" HTTP::uri $uri_to_save } } } }
- Lolo_17756
Nimbostratus
The last script work verry fine
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