URL structures are an important part of SEO. Its very important that our sites do not appear to serve duplicate content. However there is one feature of EPiServer that can do exactly that, namely when using language branches in the URL and viewing content in the master langauge.

The Problem

For example, even with Globalisation switched off, this particular post could be accessed on the two following URLs:

  • http://www.david-tec.com/2011/04/Using-IIS7s-URL-Rewrite-feature-to-enable-good-SEO-practice-in-EPiServer/
  • http://www.david-tec.com/en/2011/04/Using-IIS7s-URL-Rewrite-feature-to-enable-good-SEO-practice-in-EPiServer/

Google and SEO people in general do not like this and see it duplicate content. The normal approach is to use a canonical URL to let Google know that the "/en/" version of the page is not the original one.

However I was never wholly satisfied with that as we should never (ever) need to serve up content on the /en/ branch as its the master language anyway. 

I've used solutions in the past that have used 3rd party rewriters to get around this problem. However this never seemed a decent solution as we are adding more code into our solutions. 

The solution

IIS7 has a URL rewrite feature that can do this for us very easily. To enable a 301 redirect of all "/en/" requests simply set the rule as follows (IIS > Your Site > URL Rewrite):

If you don't have this feature installed then you can either use the Web Platform Installer or download it directly here: http://www.iis.net/download/urlrewrite

Or for those that are more inclined to do this in code then the following entry in the <system.webServer> element in web.config does the trick:


  
    
      
      
    
  

Conclusion

This solution is already in use on this site so I can confirm it works!

Feedback

Please feel free to comment below or twitter me with any feedback @davidknipe


Comments

Recommendations for you