Forum Discussion
Darren_Person_2
Nimbostratus
Mar 07, 2007Vanity Url - Re-write URL
Hi!
As many of you who do .NET development on IIS know, creating a system to have clean URLs is very complex. I was hoping that we could leverage the F5 to assist, but am stuck as to how to...
hoolio
Cirrostratus
Mar 07, 2007It should be fairly straightforward to implement that logic in an iRule. You can use the 'HTTP::uri' command in the HTTP_REQUEST event to get/set the URI. You can use string functions to parse/modify the URI.
Here's a quick draft:
when HTTP_REQUEST {
if the web app is case-insensitive, save the URI in lowercase
set uri [string tolower [HTTP::uri]]
log the lowercase version of the URI before modifying it
log local0. "lowercase uri: $uri"
check for the three logical cases
if { $uri=="/" }{
log local0. "URI was /: \$uri: $uri"
do nothing
}
elseif { $uri ends_with "/" }{
log local0. "URI ended with /: \$uri: $uri"
replace the trailing / with .html
set $uri [concat [string trimright $uri "/"].html]
}
elseif { not ($uri ends_with ".html" }{
log local0. "URI didn't end with .html: \$uri: $uri"
append .html
set $uri [concat $uri.html]
}
else {
did we miss a case?
log local0. "default: \$uri: $uri"
}
log local0. "updated \$uri: $uri"
update the URI before sending the request to the pool
HTTP::uri $uri
}Note that I didn't test all cases/exact syntax, but hopefully this gets you started.
The log statements are written to /var/log/ltm. They should help you trace what the rule is doing. You should comment them out or remove them before using the rule in production.
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
