<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fredrik Haglund's blog &#187; SEO</title>
	<atom:link href="http://blog.fredrikhaglund.se/blog/tag/seo/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fredrikhaglund.se</link>
	<description>Chatter about EPiServer, ASP.NET, CSS and Web Development.</description>
	<lastBuildDate>Tue, 28 Jun 2011 13:37:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>EPiServer SEO: Reduce Duplicate Content Links</title>
		<link>http://blog.fredrikhaglund.se/blog/2009/02/15/episerver-seo-reduce-duplicate-content/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2009/02/15/episerver-seo-reduce-duplicate-content/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 19:12:35 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ConvertedToExternal]]></category>
		<category><![CDATA[epslanguage]]></category>
		<category><![CDATA[FriendlyUrlRewriteProvider]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[UrlRewriteModule]]></category>
		<category><![CDATA[UrlRewriteProvider]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/blog/2009/02/15/episerver-seo-reduce-duplicate-content/</guid>
		<description><![CDATA[Google and other search engines does not like duplicate content. The reason is that the page&#8217;s reputation (or page rank) is calculated from incoming internal and external links. If you have more links leading to the same page the reputation will be split between the URLs. One an EPiServer site with English as default language [...]]]></description>
			<content:encoded><![CDATA[<p>Google and other search engines does not like duplicate content. The reason is that the page&#8217;s reputation (or page rank) is calculated from incoming internal and external links. If you have more links leading to the same page the reputation will be split between the URLs.</p>
<p>One an EPiServer site with English as default language in siteHosts-tag the start page can usually be reached by the following two URLs. (<a href="http://world.episerver.com/en/Documentation/Items/Tech-Notes/EPiServer-CMS-5/EPiServer-CMS-5-R2-SP1/Globalization/#Scenario%202%20-%20Local%20Domains%20Mapped%20to%20Languages" target="_blank">Read more about siteHosts, Globalization and how to set the default language for a domain</a>.)</p>
<ol>
<li><a href="http://www.mydomain.com/">www.mydomain.com/</a></li>
<li><a href="http://www.mydomain.com/en/">www.mydomain.com/<strong>en</strong>/</a></li>
</ol>
<p>EPiServer&#8217;s Friendly URL Rewriter adds &#8220;/en&#8221; to the beginning to select Language Branch if the internal URL contains the query parameter <em>epslanguage</em>.  So you can have a lot of both URLs on your site, both leading to the same page.</p>
<p>One recommended strategy to handle multiple URLs to the same page is to use 301 Redirection but that is a topic for another blog post (Ted Nyberg had a good post about this some time ago). In this post I want to show you how easy it is to tweak EPiServer&#8217;s Friendly URL Rewriting to eliminate duplicate URLs caused by language.</p>
<h3>Example of how to tweak EPiServer&#8217;s Friendly Url Rewriter</h3>
<pre class="csharpcode">
<span class="kwrd">public</span> <span class="kwrd">class</span> Global : EPiServer.Global
{
    <span class="kwrd">protected</span> <span class="kwrd">void</span> Application_Start(Object sender, EventArgs e)
    {
        EPiServer.Web.UrlRewriteModule.HttpRewriteInit += UrlRewriteModule_HttpRewriteInit;
    }

    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// This adds the hooks to the UrlRewriter instance</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="kwrd">private</span> <span class="kwrd">void</span> UrlRewriteModule_HttpRewriteInit(<span class="kwrd">object</span> sender, UrlRewriteEventArgs e)
    {
        UrlRewriteModuleBase module = sender <span class="kwrd">as</span> UrlRewriteModuleBase;
        <span class="kwrd">if</span> (module != <span class="kwrd">null</span>)
        {
            module.HtmlAddingRewriteToExternalFilter += module_HtmlAddingRewriteToExternalFilter;
            UrlRewriteProvider.ConvertedToExternal += UrlRewriteProvider_ConvertedToExternal;
        }
    }

<span class="rem">    /// &lt;summary&gt;</span> 

    <span class="rem">/// Remove language from path if it is the default for the hostname.</span>

    <span class="rem">/// &lt;/summary&gt;</span> 

    <span class="kwrd">private</span> <span class="kwrd">void</span> UrlRewriteProvider_ConvertedToExternal(<span class="kwrd">object</span> sender, UrlRewriteEventArgs e)
    {
        <span class="kwrd">if</span> (e.IsModified)
        {
            <span class="kwrd">string</span> lang = LanguageSelection.GetLanguageFromHost();
            <span class="kwrd">if</span> (e.Url.Path.StartsWith( <span class="str">'/'</span> + lang + <span class="str">'/'</span>))
            {
                e.Url.Path = e.Url.Path.Substring(lang.Length + 1);
            }
        }
    }

    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// Prevent Rewrite To External for Trace.axd and </span>

<span class="rem">    /// other locations I do not want EPiServer to interfere with.</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="kwrd">private</span> <span class="kwrd">void</span> module_HtmlAddingRewriteToExternalFilter(<span class="kwrd">object</span> sender, UrlRewriteEventArgs e)
    {
        <span class="kwrd">string</span> path = e.Url.Path.ToLowerInvariant();
        e.Cancel = e.Cancel || path.EndsWith(<span class="str">"trace.axd"</span>) || path.StartsWith(<span class="str">"/MyWebApp"</span>)

<span class="rem"> </span>   }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2009/02/15/episerver-seo-reduce-duplicate-content/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

