A client recently asked me if it was possible to create a friendly url for a specific page on their site. The regular URL looked like this: http://[Host Domain]/en/Help/tabid/89/Default.aspx. This is ok, but not real friendly so I added a rule to SiteUrls.config
This results in a much friendlier URL: http://[Host Domain]/en/Help/Default.aspx. The client thought that was good, but they wanted it even friendlier. They didn't want to have the Default.aspx in the URL so that it would just be: http://[Host Domain]/en/Help/. I started scratching my head. This was a big problem because without the .aspx file, then IIS would handle the request as a simple directory request and would never call ASP.Net ISAPI, which would mean our UrlRewriter would never be called.
But then it struck me. What if I just created a directory in IIS so that it had an actual directory to work with? Well this didn't exactly work because I was still left with IIS trying to handle the request itself. So I added an empty file called default.aspx to the new directory. Since default.aspx is one of the default filenames, IIS found the file and called ASP.Net, which handed the call off to DNN and the UrlRewriter. This works, but I am not really happy since this requires a physical directory corresponding to each friendly URL.
So I created a "VirtualFriendlyUrl" directory in my DNN directory with the dummy default.aspx. After I had a single physical directory, then I could create as many IIS Virtual Directories which pointed to my placeholder directory. Now I have a single physical directory, and a bunch of virtual directories, which should make maintenance much easier going forward. Like many things in DNN, thinking outside the box can sometimes result in some simple and elegant solutions to otherwise difficult problems.