Forum Discussion
dexter_22020
Jan 16, 2012Nimbostratus
apache rewrite PT to iRules
Hello,
Newbie on iRules here seeking help from you gurus.
I want to move this apache functionality to the Big-IP using iRules but I don't even know how to begin se...
hooleylist
Jan 16, 2012Cirrostratus
Hi,
I think this should be equivalent to the Apache rewrite rule:
when HTTP_REQUEST {
Check if the host is test.domain.com and the path does not already start with /web/foo
if {[string tolower [HTTP::host]] eq "test.domain.com"}{
if { not ([HTTP::path] starts_with "/web/foo")}{
Prepend /web/foo to the path
HTTP::path "/web/foo[HTTP::path]"
}
}
}
And here's a version which works with a stream profile to rewrite the response content and redirect Location header from /web/foo to nothing:
when HTTP_REQUEST {
Disable the stream filter by default
STREAM::disable
Check if the host is test.domain.com and the path does not already start with /web/foo
if {[string tolower [HTTP::host]] eq "test.domain.com"}{
if { not ([HTTP::path] starts_with "/web/foo")}{
Prepend /web/foo to the path
HTTP::path "/web/foo[HTTP::path]"
}
}
}
when HTTP_RESPONSE {
Rewrite redirects
if {[HTTP::is_redirect] && [URI::path [HTTP::header Location]] starts_with "/web/foo"}{
HTTP::header replace Location [string map {/web/foo ""} [HTTP::header Location]]
}
Set the stream expression for text responses
if {[HTTP::header Content-Length] contains "text"}{
STREAM::expression {@/web/foo@@}
STREAM::enable
}
}
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