Extension less URL Rewriting

Extensionless URL’s are more user and search engine friendly. Overall, you can make your website URL’s more meaningful and less difficult to remember.

Development steps:-

1.       We need to add a third party URL rewriter assembly. Many such assemblies are available. I used URL Rewriter assembly “Intelligencia.UrlRewriter”. This assembly would change all your URL’s, you just need to let the system know what URL’s to use through web.config.

 

2.      For IIS 7 you might need to make changes in applicationhost config file to permit IIS applications to use handlers and modules. Please check to make sure following sections have “allow” permissions. Application host file is located at c:/windows/system32/inetsrv/config/ applicationHost.config

<section name=”globalModules” allowDefinition=”AppHostOnly” overrideModeDefault=”Allow” />

<section name=”modules” allowDefinition=”MachineToApplication” overrideModeDefault=”Allow” />

<section name=”handlers” overrideModeDefault=”Allow” />

 

3.      Add configurations as mentioned below in your web.config.

<configuration>

  <configSections>

    <section name=”rewriter” requirePermission=”false”

       type=”Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter” />

  </configSections>

 

  <system.web>  

    <httpModules>

      <add name=”UrlRewriter” type=”Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter” /> // Assembly name of the URL rewriter assembly

    </httpModules>   

  </system.web>

 

  <system.webServer>

    <modules runAllManagedModulesForAllRequests=”true”>

      <add name=”UrlRewriter” type=”Intelligencia.UrlRewriter.RewriterHttpModule” />

    </modules>

 

    <validation validateIntegratedModeConfiguration=”false” />

  </system.webServer>

 

 

 4) Use following URL rewrites. In below mentioned URL your URL will be http://www.xyz.com/myprofile and your application url would be “http://www.xyz.com/Profile.aspx”

<rewriter>

   // This is the place where we write our rewriting rule like

 <rewrite url=”~/MyProfile$” to=”~/Profile.aspx” ignoreCase=”true” />

  </rewriter>


« Another breaking change in ASP.NET 2.0: Session.SessionID
Open Source CMS Systems »


Leave a Reply