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...
hoolio
Cirrostratus
Jan 18, 2008Hi,
Here would be an equivalent to the apache rewrite rule:
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
You can use the regexp command (Click here), to evaluate the regex and save the matches into backreferences. To set the HTTP host header, you can use 'HTTP::header replace Host $new_value'. To set the URI, you can use HTTP::uri $new_uri. If you wanted to send the client a redirect, instead of rewriting the host or URI, you could use 'HTTP::redirect $fully_qualified_url'.
You don't have an exact match to the syntax of Apache's mod_rewrite, but there is equivalent functionality using iRules.
Aaron
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