Solve the problem of slashes in URLs

Whether you chose to use a suffix or not in URLs, there is still the problem of slash at the end of the address. This can cause problems with duplicate content.

Magento (also found this problem on many Web applications), it is always possible to display a page with or without a slash at the end of the URL. Try on your shop, it is likely that the two addresses displayed the same content. For example:
•CMS page “demo-page” and ” demo-page/”
•Product: “watch-dc.html” and “watch-dc.html/”

However, these addresses do not have the same meaning. A URL containing a final slash denotes a directory, URL not containing denotes a file. It is therefore possible to serve different content on the two addresses.

That’s why Google manages two distinct URLs. An article in the Webmaster Central Blog makes clear: To slash or not to slash .

Google treats Each URL above separately (and Equally) Regardless of Whether it’s a file or a directory, or it contains a trailing slash or it Does not Contain a trailing slash.

To overcome this problem, Google suggests using the Canonical URL or apply a 301 redirect. In all cases you must make a choice: always use a slash in the URL of your site or not. Once this choice is made must be consistent in the links on the site.

Many Magento modules are available to add to the header of the page canonical URL. Instead, we’ll look at the 301 redirect. In the case there is a redirection longer possible ambiguity.

This happens in. Htaccess. In this example I treat the classical scheme:

Product pages and categories with an extension without trailing slash (eg “product.html”)
CMS pages (controllers) without suffix with a trailing slash (eg “page/”)

Note that I make a redirection addresses containing between 1 and 255 slashes, because it is possible to specify an infinite number.

Warning: beware of the URLs of your forms, if a 301 redirect is performed because the address specified in action is different from that selected, the data will not be transmitted.
I recommend testing all pages of the site and the ordering process after adding redirects.

Leave a Comment

Your email address will not be published. Required fields are marked *

*