Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

K Khan
Dec 2, 2014
  5171
(1 votes)

Trailing slashes in website

Trailing slashes in your website.
We got some SEO requirements for a website that
1. All the links in website either should have a trailing slash (preferred) or not.
2. Further if user enters www.site.com it should automatically redirect to www.site.com/ . Our site is a commerce site and using DefaultHierarchialRouter for commerce routing.

For the first requirement solution is very simple. In some initialization module we can force trailing slash for the website using EPiServer.Web.Routing.ContentRoute.UseTrailingSlash = true;

For the 2nd requirement in 7.5 multiple suggestion came by Quan and Johan. You can find those details under thread http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=113080. But we preferred to install IIS rewrite module to solve this issue, that can be downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=5747 and can be setup http://thatsit.com.au/seo/tutorials/how-to-fix-canonical-issues-involving-the-trailing-slash 
We requires some extra rules to avoid trailing slash for online center, images, and other static contents. You can find a general rule set for an episerver site as following
<rule name="AddTrailingSlashRule1" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{URL}" pattern="/bundles/" negate="true" />
<add input="{URL}" pattern="/cm/UI/" negate="true" />
<add input="{URL}" pattern="/App_Themes/" negate="true" />
<add input="{URL}" pattern="/util/" negate="true" />
<add input="{URL}" pattern="/SearchAction" negate="true" />
<add input="{URL}" pattern="/Index" negate="true" />
<add input="{URL}" pattern="/globalassets/" negate="true" />
</conditions>
<action type="Redirect" url="{R:1}/" />
</rule>

Dec 02, 2014

Comments

Johan Book
Johan Book Dec 4, 2014 09:19 AM

Is there really a SEO difference between a URL with- and without trailing slash? IMO they should be treated the same way. Then again, I'm not google ;-)

K Khan
K Khan Dec 4, 2014 11:37 AM

Requirement was that there must not be mix of urls. either whole site should be with trailing slash or whole site should be without trailing slash.

Technically, Urls may look similar and even can take a visitor to the same url, but they can be very different, from an SEO perspective. e.g. a trailing slash in one URL could be read by search engines as two separate and different URLs. This can create the potential for duplicate content issues to arise, which can confuse search engines.

When trailing slashes are used in URLs for backlinking, Google will recognize those Web pages differently than a main page that has no trailing slash.

http://googlewebmastercentral.blogspot.co.uk/2010/04/to-slash-or-not-to-slash.html

Justin Le
Justin Le Dec 5, 2014 08:48 AM

One note on using iis rewrite is that you might have issue with multiple redirection. For example if you have two rule: first one is add trailing slash and second one is force lower url. Then when you type: www.site.com/Abc, browser will make two redirection www.site.com/Abc -> www.site.com/Abc/ -> www.site.com/abc/, which is bad for SEO.

I would suggest to extend the default router and using SegmentContext.PermanentRedirect(string url) to redirect your url. Then you could force lower case and add ending trail if missing.

K Khan
K Khan Dec 5, 2014 11:25 AM

Well, Lower case is resolved in initialization module EPiServer.Web.UrlSegment.UseLowerCaseSegments = true;
I am agreed SegmentContext.PermanentRedirect is best solution as a permanent fix.

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog