Prioritize folders in URL rewrite for IIS7

122 views Asked by At

We are currently using CommunityServer for our website.

A recent change called for the creation of a shorter URL to access a user's profile page. So if our site is www.example.com, we want the user profile page to be accessible via www.example.com/username.

To make sure that existing folders/paths are prioritized, I placed the rewriting rule at the very end in SiteUrls.config:

<Override xpath = "/SiteUrls/locations/location[@path='/']" mode="add" where="end">
       <url name="userslug" path="" pattern="/([a-zA-Z0-9\-]+$)" physicalPath="/user/" vanity="{2}?slug=$1" page="userprofile.aspx"  />
</Override>

This worked quite well while testing in my local environment via VS2010 Debug. Accessing www.example.com/folder gets redirected to www.example.com/folder/ and the default page is shown properly.

However, when we deployed the change to live, accessing www.example.com/folder returns a user not found error, which just means that looking for an existing folder was not prioritized somehow.

I'm not sure what relevant information to give from our live server, but is there anything I should take a look at to make the URL access work like how it is in VS2010 Debug?

1

There are 1 answers

0
rikitikitik On BEST ANSWER

Apparently, all you got to do is to create a URL Rewrite rule to add trailing slashes to directories via IIS.