Quantcast
Viewing latest article 5
Browse Latest Browse All 10

ASP.NET URL rewrites

The Planetdomain Windows servers do not have an inbuilt URL rewrite module installed. A 3rd party module such as UrlRewritingNet is required to rewrite URL’s on the Planetdomain Windows environment.

To rewrite URL’s on the Planetdomain Windows environment

  1. Download UrlRewritingNet.UrlRewriter.dll.
  2. Create a bin directory on the Windows virtualhost.
  3. Upload the UrlRewritingNet.UrlRewriter.dll file into the bin directory.
  4. Configure a web.config file to utilise the rewrite module.
  5. Upload the web.config file into the root directory of the virtualhost

Note that the <configSections> element within the web.config file must be the first element after the <configuration> element for the function to work correctly.

Example web.config file using UrlRewritingNet to rewrite URL’s.

<configuration>
<configSections>
<section name=”urlrewritingnet” restartOnExternalChanges=”true”  requirePermission=”false” type=”UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter” />
</configSections>

<system.webServer>
<httpErrors errorMode=”Detailed” />
<modules>
<add name=”UrlRewriteModule” type=”UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter”/>
</modules>
</system.webServer>

<system.net>
<defaultProxy>
<proxy
usesystemdefault = “false”
proxyaddress=”http://proxy.private.netregistry.net:3128″
bypassonlocal=”true”
/>
</defaultProxy>
</system.net>

<urlrewritingnet rewriteOnlyVirtualUrls=”true” contextItemsPrefix=”QueryString” defaultPage=”default.aspx”  xmlns=”http://www.urlrewriting.net/schemas/config/2006/07″ >
<rewrites>

<add name=”GetProductCategories”  virtualUrl=”^~/Categories/(.*).html”  rewriteUrlParameter=”IncludeQueryStringForRewrite”  destinationUrl=”~/test.aspx”  ignoreCase=”true” />
<add name=”GetProduct” virtualUrl=”^~/Products/(.*).html”  rewriteUrlParameter=”ExcludeFromClientQueryString”  destinationUrl=”~/test.aspx”  ignoreCase=”true” />
</rewrites>
</urlrewritingnet>

</rewrites>
</urlrewritingnet>
</configuration>

Example of a web.config using UrlRewritingNet to rewrite and redirect sub domain URL’s into sub directories.

<configuration>
<configSections>
<section name=”urlrewritingnet” restartOnExternalChanges=”true”  requirePermission=”false” type=”UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter” />
</configSections>

<system.webServer>
<httpErrors errorMode=”Detailed” />
<modules>
<add name=”UrlRewriteModule” type=”UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter”/>
</modules>
</system.webServer>

<system.net>
<defaultProxy>
<proxy
usesystemdefault = “false”
proxyaddress=”http://proxy.private.netregistry.net:3128″
bypassonlocal=”true”
/>
</defaultProxy>
</system.net>

<urlrewritingnet rewriteOnlyVirtualUrls=”true” contextItemsPrefix=”QueryString”  xmlns=”http://www.urlrewriting.net/schemas/config/2006/07″ >
<rewrites>

<add name=”RewriteOne” virtualUrl=”^http\://(.*).domain.tld/(.*)” rewriteUrlParameter=”ExcludeFromClientQueryString” destinationUrl=”$1/$2″ rewrite=”Domain” ignoreCase=”true” />

</rewrites>
</urlrewritingnet>
</configuration>


Viewing latest article 5
Browse Latest Browse All 10

Trending Articles