URL rewriting. So, so close!!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 лет назад
My quest for extensionless URLs continues.
I have got this almost working using the IIS7 rewrite module.
I have now got my URL looking like:

http://www.mysite.com/art/12/lovely_picture

but it seems I have also rewritten something I shouldn't have because I now can't login ;)

Help anyone?...

here is my system.webserver section
<rewrite>
      <rules>
        <rule name="Default Redirect" stopProcessing="true">
          <match url="^default\.aspx$" />
          <action type="Redirect" url="/" redirectType="Permanent" />
        </rule>
        <!--<rule name="Redirect aspx to extensionless" stopProcessing="true">
          <match url="(.*)\.aspx" />
          <action type="Redirect" url="{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="redirect default extensionless document" stopProcessing="true">
          <match url="(.*)default" />
          <action type="Redirect" url="{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="rewrtie the aspx extension">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll">
            <add input="{URL}" negate="true" pattern="\.axd$" />
            <add input="{URL}" negate="true" pattern="\.js$" />
            <add input="{URL}" negate="true" pattern="\.ashx$" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="{R:1}.aspx" redirectType="Permanent"/>
        </rule>-->
      </rules>
    </rewrite>

my urlrewritingnet config:
{0}art/{1}/{2}
{0}craft/{1}/{2}

    <add name="ProductDetailsRewrite" virtualUrl="^~/art/([0-9]*)/([\w-]*)"
         rewriteUrlParameter="ExcludeFromClientQueryString"
         destinationUrl="~/Product.aspx?ProductID=$1&amp;$3"
         ignoreCase="true"  />
    <add name="CategoryDetailsRewrite" virtualUrl="^~/craft/([0-9]*)/([\w-]*)"
         rewriteUrlParameter="ExcludeFromClientQueryString"
         destinationUrl="~/Category.aspx?CategoryID=$1&amp;$3"
         ignoreCase="true" />
14 лет назад
Sorted!!

What I did was, I got a thousand monkeys and a thousand typwriters and eventually they came up with this!


<system.webServer>
    <rewrite>
      <rules>
        <rule name="Default Redirect" stopProcessing="true">
          <match url="^default\.aspx$" />
          <action type="Redirect" url="/" redirectType="Permanent" />
        </rule>
        <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
          <match url="^([a-z-]+)/([_0-9]+)/([0-9a-z-]+)\.aspx$" />
          <conditions>
            <add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" />
          </conditions>
          <action type="Redirect" url="{R:1}/{R:2}/{R:3}" appendQueryString="false" redirectType="Permanent" />
        </rule>
        <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
          <match url="^([a-z-]+)/([_0-9]+)/([0-9a-z-/.]+)$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="{R:1}/{R:2}/{R:3}.aspx" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>


The old methods are the best. ;)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.