Forum Discussion
Phil_Agee_69879
Nimbostratus
Dec 14, 2005URL Rewriting
We are just getting started with iRule and are curious about the capability to rewrite URLs.
According to the following link (Joe Pruitt's log):
http://devcentral.f5.com/weblogs/Joe/archive/2005/07/27/1397.aspx
to rewrite a URL without changing the URL that the browser shows in the address bar, we can use something like:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/foo" } {
HTTP::uri "/bar"
}
}
What we are looking for is to rewrite as follows:
http://www.domain.com/MyName
to
http://www.domain.com/CustomerHomePage.aspx?CustomerName=MyName
Would the rulle be something like:
when HTTP_REQUEST {
if( [HTTP]::uri /(/w+)/? {
HTTP::uri "/MyPage.aspx\?Param=$1"
}
}
Thanks Very Much,
Phil
- JRahm
Admin
Try this:when HTTP_REQUEST { if { [HTTP::uri] starts_with "/MyName" } { HTTP::uri "/CustomerHomePage.aspx?CustomerName=[HTTP::uri]" } }
- JRahm
Admin
Forgot to trim the leading /.... try this instead:when HTTP_REQUEST { if { [HTTP::uri] starts_with "/MyName" } { set uri [string trimleft [HTTP::uri] "/"] HTTP::uri "/CustomerHomePage.aspx?CustomerName=$uri" } }
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