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 begin. Given that the .NET pipeline always wants a file extension and we don't want to wildcard map all file extensions to go through the ASP.NET work process - we thought we could use the F5 to help us.
In IIS, we would write an HTTPModule and assign the ASP.NET pipleline for the file extension of .html.
Here are our business rules:
1. If the F5 receives a URL that does not contain a file extension it should append .HTML to the URL.
2. If the URL ends with a '/' the '/' should be removed before appending .HTML.
3. If the URL points to the root of the site .HTML should not be appended.
Can someone please help with how we should begin?
Thanks!!
- hoolio
Cirrostratus
It 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.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 }
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