Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Url rewrite the root url

I have the follow rule in IIS7:

    <rule name="RewriteAll" stopProcessing="true">
      <match url="^([^/]+)/?$" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{URL}" negate="true" pattern="\.axd$" />
        <add input="{URL}" negate="true" pattern="\.png$" />
        <add input="{URL}" negate="true" pattern="\.gif$" />
        <add input="{URL}" negate="true" pattern="\.jpg$" />
        <add input="{URL}" negate="true" pattern="\.css$" />
        <add input="{URL}" negate="true" pattern="\.js$" />
      </conditions>
      <action type="Rewrite" url="default.aspx?page={R:1}" />
    </rule>

That catch urls like http://mysite.com/contact/

I can't figure out with rule to use to catch http://mysite.com/ and send to for example home.aspx. Can anyone help me with the match regex

like image 845
Ivo Avatar asked Dec 05 '22 22:12

Ivo


1 Answers

I fixed it by adding the following rule:

 <rule name="Index Request" enabled="true" stopProcessing="true">
     <match url="^$" />
     <action type="Rewrite" url="index.aspx" logRewrittenUrl="true" />
 </rule>
like image 111
Ivo Avatar answered Feb 03 '23 01:02

Ivo