« Previous Next »

Thread: Rewriting the home page

Last post 10-05-2009 6:08 PM by ruslany. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 10-03-2009, 6:02 AM

    • higgsy
    • Not Ranked
    • Joined on 02-06-2009, 3:26 PM
    • Posts 3

    Rewriting the home page

     Hi,

    Im using the IIS 7 Rewrite module to rewrite pages/directories. All is working fine apart from the home page. My syntax is as so:

    <rewrite>
                <rules>
                    <rule name="Add trailing slash" stopProcessing="false">
                        <match url="(.*[^/])$" />
                            <conditions>
                                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            </conditions>
                        <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
                    </rule>
                    <rule name="Rewrite home page">
                        <match url="/" ignoreCase="true" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="/lib/pages/default.aspx" />
                    </rule>
                    <rule name="Rewrite about page">
                        <match url="^about" ignoreCase="true" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="/lib/pages/default.aspx" />
                    </rule>
                </rules>
            </rewrite>

    When i navigate to my home page, the InputUrl is blank, therefore it wont match the single slash i have provided, but also i cant provide url="".

    Regular expressions arent my thing, so if anyone knows the right syntax it would be much appreciated.

    Thanks in advance.

    Al

  • 10-03-2009, 2:14 PM In reply to

    Re: Rewriting the home page

    Are you redirecting your documents to extensionless? I'm asking because you have '^about' instead of 'about.aspx', you could try using the following for your 'Rewrite home page' rule.
    <match url="/default" ignoreCase="true" />
    or
    <match url="/default.aspx" ignoreCase="true" />
    depending on whether you are using extensions or not. For my site I redirect *.aspx to extensionless, redirect '/default' to '/'  Then rewrite the extensionless documents back to .aspx. Documents that requested the default document i.e '/' get rewritten to 'default.aspx'. You can take a look at my post here

    http://forums.iis.net/t/1161355.aspx

  • 10-05-2009, 6:08 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: Rewriting the home page

    You could try url="^$" which will match the empty URL.

    http://ruslany.net
Page 1 of 1 (3 items)
Microsoft Communities