1

I ran a page seo and it said I needed to remove the trailing slash because it could cause duplicate content. So I found this rule:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

and added it to the htaccess but now I can't pass the Billing Information step in the onepage checkout.

Is this rule correct? Why can't I pass the Billing step?

| improve this question | | | | |
3

This is not required if you activate the canonical URLs under System > Configuration. This will prevent Google from indexing the page on different URLs

canonical settings

| improve this answer | | | | |
  • I was also thinking about the other search engines. Use Canonical Link Meta Tag For Categories because each category page is different. I use this: print_r ($_SERVER['QUERY_STRING']); in my meta title tag to display p=2 so I don't get duplicate title tag warnings. I use Canonical for pages thou. Wonder why removing the slash makes it where magento can't check out? – Freejoy Jan 17 '16 at 15:46
  • It will also work for other search engines. This is basically the way to go and will solve a lot more issues next to slash also regarding layered navigation and pagination. – Sander Mangel Jan 18 '16 at 7:41
  • @Sander Thank you for your answser. I just want to let you know that it will not work in the case of other page (CMS Page and cart page etc) – Vikas Verma Jul 21 '17 at 6:35
1

This removes trailing slashes and redirects uppercase to lowercase as well

# Remove trailing slashes (consider backend)
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/downloader.*$
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.*)/$ /$1 [L,R=301] 

# Eugene: Redirect uppercase to lowercase
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} [A-Z]
# need RewriteMap lc int:tolower in VirtualHosts httpd.conf
RewriteRule (.*) /${lc:$1} [R=301,L]
| improve this answer | | | | |
  • where do you add this code? – jibin george Feb 3 at 13:42
  • .htaccess (usually in www folder for Apache httpd web server), see the comment about lc function in httpd.conf as well (last line) – Eugene Lycenok Feb 6 at 3:09
0

You can use below code in your .htaccess file.

# remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]

I have used this and this is working fine for me.

When you will enable the Use Canonical Link Meta Tag For Categories and Use Canonical Link Meta Tag For Product in System > Configuration > Catalog > Search Engine Optimization. This is right that slash will not effect your Seo ranking(Duplicate URL Issue). But, this will work for only Categories and Products. It will not work for other pages.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.