Forum Discussion
Alex_3268
Nimbostratus
Jan 18, 2008Performaing complex Apache like rewrites
Hi,
I've been searching and reading this forum and others for information on replacing Apache rewrites with iRules but I'm still somewhat confused as to whether this is entirely possible and if it's even a good idea in the first place.
An example of the type of rewriting we do now is;
RewriteRule ^/([a-z])ws/wfs([a-z]+)_([0-9]+)/(wfs|wms)/(.*)$ \
http://hostname/wfs$2_$3/$4/$5
There are a number of variations on the above. We do this to partially validate the parameters but mainly to provide a consistent uri format across a variety of applications.
From what I've read so far it appears doing this using iRules would be somewhat more complex and require pulling apart the uri, placing the components into variables, doing string matches and probably data group lookups, then putting it all back together?
Is there an easier way (ideally something very similar to Apache)?
Any help or advice would be greatly appreciated.
- hoolio
Cirrostratus
Hi,Evaluate the regex against the HTTP host and URI. Save the 5 backreferences to match1 through match5 for later use regexp {^/([a-z])ws/wfs([a-z]+)_([0-9]+)/(wfs|wms)/(.*)$} [HTTP::host][HTTP::uri] m1 m2 m3 m4 m5 log local0. "New Host: hostname" HTTP::header replace Host "hostname" Escape the variable name using curly braces where necessary log local0. "New URI: /wfs${m2}_$m3/$m4/$m5" HTTP::uri /wfs${m2}_$m3/$m4/$m5
- Alex_3268
Nimbostratus
Thanks Aaron, that looks like the thing I'm after. I'm wondering though, would I need to do anything for the HTTP_RESPONSE event? - hoolio
Cirrostratus
Hi,
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