Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The IIS Manager has a GUI / wizard interface for creating the rules which I usually find quicker and easier than entering the rule into the web.config file manually. Worth checking out: <code>IIS Manager -&gt; select your site / application -&gt; URL Rewrite -&gt; Add Rule(s)</code>.</p> <p>I think the following rule will do the trick for you:</p> <pre><code>&lt;rule name="RewriteUserFriendlyURL1" stopProcessing="true"&gt; &lt;match url="^([^/]+)/?$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt; &lt;/conditions&gt; &lt;action type="Rewrite" url="default.aspx?folder={R:1}" /&gt; &lt;/rule&gt; </code></pre> <p>Basically, the "match url" is a <a href="http://www.regular-expressions.info/" rel="nofollow">regular expression</a> that is used to identify a part of the URL. In this case, it captures a group containing one or more characters (except for a /), with an optional / at the end of the URL. It will then rewrite the url to <code>default.aspx?folder=</code> followed by the value that was matched (<code>{R:1}</code> refers to the first captured group, which will contain the folder name).</p> <p>This will work provided you only have a single subfolder name (not nested folders).</p> <p>You could also add a second rule which works in the opposite direction, so browsing to <code>http://www.example.com/default.aspx?folder=myfolder</code> would result in the user seeing <code>http://www.example.com/myfolder</code>:</p> <pre><code>&lt;rule name="RedirectUserFriendlyURL1" stopProcessing="true"&gt; &lt;match url="^default\.aspx$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /&gt; &lt;add input="{QUERY_STRING}" pattern="^folder=([^=&amp;amp;]+)$" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="{C:1}" appendQueryString="false" /&gt; &lt;/rule&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload