I have a site built in Magento 1.9 that has the same page linked differently in different places. In some places it is linked as /contact-us
and in others it is linked as /contact-us/
. Magento is treating these as two different pages. For SEO purposes we want these two to appear as the same single page.
I tried implementing a custom URL Rewrite in the Magento admin and set the request path to: contact-us
, and the target path to: contact-us/
, and this effectively adds the /
to the end of the path, but somehow this ends up triggering a redirect loop.
Can anyone advise?
From everything I could find this trailing slash issue could not be fixed using the URL Rewrite section in the Magento admin menu.
I was able to solve this by directly modifying the root .htaccess
file and adding the following:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
Sharing in case this is helpful for anyone else.