Thursday, October 6, 2016

Fixing shortcomings in

One of my current projects, allows for the customer to create their own pages on the fly. As such, I needed to create a URL Rewriter so that they could create Search Engine friendly URLs. During my hunt I came across URL Rewriter .NET, an open source solution.

The initial problem that I ran into is, that it disables handling of the default page handlers. After following their suggestions and adding the following expression to handle default pages, I realized it didn't handle subdirectories very smoothly.

<rewrite url="^(.*)/(\?.+)?$" to="$1/default.aspx$2" processing="stop">

Basically, would resolve fine. would return a 404 not found error. For now, until I get a chance to look through the source code and find the cause of the problem, I thought I would give you a work around.

<redirect url="(.*)/test$" to="$1/test/" processing="stop">

For this, it looks for the URL to end in the directory name, without a trailing slash. If it matches this case, it redirects the URL to the same location with a trailing slash. Luckily the application uses Regular Expression (RegEx) to parse the URL. Admittedly, this is a weak point for me, so it'll take some time before I can really find a nice solution for this project.

Overall, it's not a terrible solution, but I will probably look down the road at some better ideas. One limitation I do have, is that our primary web server is still on IIS 5.

No comments: