May 28th, 2015

How to Remove the Trailing Slash from a URL

Category:Magento SEO | Posted By Mai Erne at 10:00 AM

The trailing slash (also known as the slash that you see at the end of URL links) creates a common problem when optimizing websites for duplicate content. For instance, while elieandmai.com and elieandmail.com/ will both link to the same webpage, search engines will still divide link authority over the links, which means that the website will receive far less value.

In order to remove the trailing slash, you’ll have to implement a 301 redirection to the page with the trailing slash. This can be done with a few lines of code in the .htaccess file allowing you to redirect all incoming traffic without a trailing slash to the same URL.

This can be done with a few lines of code in the .htaccess file allowing you to redirect all incoming traffic without a trailing slash to the same URL.

elieandmai-trailing

(make sure domain.com is replaced with your root domain)

If you decide to redirect all pages with a trailing slash to an URL without trailing slash, the following code will do this for you:

elieandmai-trailing2

Explanation of this add trailing slash .htaccess rewrite rule

The first line tells Magento that this is code for the rewrite engine of the mod_rewrite module of Magento.

The 2nd line sets the current directory as page root.

No Comments for Current Post.

Comments are closed.