Prevent EPiServer UrlRewrite

Sometimes it's needed to turn off EPiServers function for Url rewrite, like if you for instance writes a link-element with a canonical url (which helps search engine optimization (SEO)). The UrlRewriteProvider works as a HTTP-module, which means that it's running after your page is rendered, parsing all your Urls in a predefined list of elements and attributes.

To prevent EPiServer's Url rewrite to occur do the following to your element:
1) Add an id-attribute to your element
2) Add a special EPiServer attribute to prevent the rewrite


Original code:
<link rel="canonical" href="the/url/not/to/rewrite" />

Updated code:
<link rel="canonical" id="canonical1" <%=EPiServer.Web.UrlRewriteProvider.UrlPreventRewriteAttribute %>="true" href="the/url/not/to/rewrite" />

Related posts:

Comments

comments powered by Disqus