Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pete 213 posts 285 karma points
    Dec 19, 2013 @ 17:01
    Pete
    0

    IIS Rewrite Module rules for Directory Urls

    I've moved a site onto a new host and as such directory urls no longer work, however the new host has the IIS rewrite module installed so I have added the following rulesto use it, but they don't seem to quite work.

    I'd like the links to be seo friendly e.g /mylink/ and not /mylink.aspx - and then to appear as /mylink/ in the address bar when navigated to.

    Here's my web.config section.

    <rewrite>
          <rules>
                    <!-- SEO: Using Directory URLs, so force trim all .aspx -->
                    <!-- exclude umbraco folder -->
                    <rule name="Trim aspx for directory URLs" stopProcessing="true">
                        <match url="(.*)\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_URI}" pattern="^/umbraco/" negate="true" />
                        </conditions>
                        <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
                    </rule>
     
                    <!-- SEO: Add trailing slash to URLs -->
                    <!-- better for SEO to *have* the trailing slash -->
                    <rule name="Add trailing slash" stopProcessing="true">
                        <match url="(.*[^/])$" ignoreCase="true" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                            <add input="{REQUEST_URI}" pattern="^/umbraco/" negate="true" />
                            <add input="{URL}" pattern="^.*\.(asp|aspx|axd|asmx|css|js|jpg|jpeg|png|gif|mp3)$" negate="true" ignoreCase="true" />
                            <add input="{URL}" pattern="/Base" negate="true" />
                            <add input="{URL}" pattern="cdv=1" negate="true" />
                        </conditions>
                        <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
                    </rule>

          </rules>
          </rewrite>

     

    With these rules I get /mylink.aspx/  , then if I turn on umbracoUseDirectoryUrls I get a 404 error on /mylink/

    Pete

Please Sign in or register to post replies

Write your reply to:

Draft