When using wildcard mapping and handling all web requests using ASP.NET, the default document settings in IIS are lost. Here’s a rule you can add at the bottom of your rule set which will give you back default document handling:

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

Note that using processing=”restart” will rerun the URL back through your rule base in case you have any earlier rules that depend on /default.aspx.

If you want to support multiple default documents like IIS does, then your default document rule will need to be a bit more complex:
<if url=”^(.*)/(\?.+)?$”>
<rewrite exists=”$1/default.aspx” to=”$1/default.aspx$2″ />
<rewrite exists=”$1/index.aspx” to=”$1/index.aspx$2″ />
<rewrite exists=”$1/index.html” to=”$1/index.html$2″ />
</if>

Be careful adding too many of these, as the file existence check is non-trivial.

Again, if you are using wildcard mapping and having ASP.NET handle every request, then you will discover that you need to add a rule to stop processing of file types that you do not want to handle (images, etc). A rule like the following at the very top of your rule set will
immediately stop rewriting anything with the extension .gif, .png,
.jpg, .ico, .pdf, .css or .js. Your situation may vary so you may want
to add other extensions:
<rewrite url=”^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js)(\?.+)?)$”
to=”$1″ processing=”stop” />

Two regular expression characters that are typically included (but not required) are the ^ and the $. ^ means the beginning of the URL, while $ means the end of the URL. Adding these at the beginning and ending of your pattern just ensures that you’re matching what you intend to match.

Using the ~/ convention if you may install your application in different web application roots (e.g., sometimes at /myapp1 and other times at /someotherplace). This way, you will not have to have different rules if your application is installed in a different virtual folder name (or even in the root of the web site).

One very useful convention is to include an optional pattern to match querystrings. If you don’t do this, then people could break your rewriting by adding a query string (?abc=123, etc).

The pattern I typically use has one of two forms:
(1) If the target url doesn’t have a custom query string:
<rewrite url=”^~/mypage(\?.+)?$” to=”~/default.aspx$1″ />

Here $1 matches (\?.+)? which matches the entire querystring.

(2) If the target url does have a custom query string:
<rewrite url=”^~/mypage(\?(.+))?$” to=”~/default.aspx?page=mypage&$2″ />

Here, you have to use & because this is an XML file and it requires the & to be escaped properly. $2 relates to (.+) which will be the querystring without the ?.