Forum Discussion
cnorgay_17044
Nimbostratus
Jan 18, 2008pls: help .....
hi gurus
convert the below from apache syntax to irules:::.thanks alot
apache syntax:
RewriteEngine on
RewriteRule ^/$ https://aaaa.bbbb.com/hp/index.php?id=30&L=0 [NC,R,L]
RewriteCond %{REQUEST_URI} ^/favicon.ico$
RewriteRule ^(.+)$ https://mylife.bbbb.com/$1 [NC,P,L]
RewriteCond %{REQUEST_URI} !^/favicon.ico$
RewriteRule ^(.+)$ https://www.cccc.com/$1 [NC,P,L]
1 Reply
- hoolio
Cirrostratus
Hello,
The first rule is rewriting requests to /favicon.ico to https://mylife.bbbb.com/favicon.ico. The net effect appears to be changing the Host header value to mylife.bbbb.com.
Here are the meanings of the rewrite flags you have listed (from the apache mod_rewrite man page Click here😞
NC - No Case (case insensitive comparison)
P - send the request to the Proxy module
L - Last (no other evaluations should be done)
RewriteCond %{REQUEST_URI} ^/favicon.ico$
RewriteRule ^(.+)$ https://mylife.bbbb.com/$1 [NC,P,L]
The second rule is redirecting any requested URI which doesn't match /favicon.ico to https://www.cccc.com/$1, where $1 is the backreference from the regex (the full URI). The net effect is that the Host header is rewritten to www.cccc.com.
RewriteCond %{REQUEST_URI} !^/favicon.ico$
RewriteRule ^(.+)$ https://www.cccc.com/$1 [NC,P,L]
Here is an equivalent iRule:
Per a note on the mod_rewrite page, the pattern is compared against the URI without the query string. In iRules you can use the command HTTP::uri to get the rule URI including the query string (/path/to/file.txt?param=value). HTTP::path returns just the path and object (/path/to/file.txt).when HTTP_REQUEST { Check requested URI (set to lower case) switch [string tolower [HTTP::path]] { /favicon.ico { Request was for the favicon.ico so rewrite Host header to mylife.bbbb.com HTTP::header replace Host mylife.bbbb.com } default { Request wasn't to /favicon.ico, so rewrite Host to www.cccc.com HTTP::header replace Host www.cccc.com } } }
For details on iRule commands, you can check the iRule wiki pages:
iRules - (Click here)
events - (Click here)
switch - (Click here)
HTTP::header - (Click here)
HTTP::redirect - (Click here)
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
