Menu
Web Design | SEO | Website Development

UK Based Web Agency, Magento & Wordpress Specialist (Cranleigh | Surrey)

Magento .htaccess SEO redirects

By In Magento Development On 25/10/2014


This is where I intend to list important .htaccess tweaks for Magento.

This codes redirects the index.php version of the homepage to the non index.php without messing up the backend access.

RewriteEngine on
RewriteCond %{THE_REQUEST} index\.php
RewriteCond %{THE_REQUEST} !admin [NC]
RewriteRule ^index\.php(.*)$ http://www.YOURSITE.com$1 [L,R=301]

You should also redirect the name of the homepage in your CMS pages to the main version

redirect 301        /home  http://www.YOURSITE.com/

This code removes the trailing slash for Magento URL to the non trailing slash version of the page.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^\.localhost$ [NC]
RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L]

These increase the SEO value of your website by reducing the number pages search engines see thereby increasing the SEO on the on the 1 you are allowing them to see.


About the Author

Dan Vince

Yet another Web Development Professional

Related Posts

4 Comments

  • dan 3 YEARS AGO

    Hi dan @ trailing slash removal: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTP_HOST} !^\.localhost$ [NC] RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L] What is the correct version for a site completely on https? just: RewriteRule ^(.+[^/])/$ https://%{HTTP_HOST}/$1 [R=301,L]? thanks dan

    Reply
  • Dan Vince 3 YEARS AGO

    Yeah i recon that'll do it.

    Reply
    • dan lee 3 YEARS AGO

      hi dan magento 1.9.1.1, all urls on https with this part: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTP_HOST} !^\.localhost$ [NC] RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L] the swatches do not work anymore. any idey? dan

      Reply
      • dan 3 YEARS AGO

        this seems to work: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(.*)/$ RewriteCond %{REQUEST_URI} !(.*)\.(html|shtml|php)$ RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301] dan

        Reply

Leave a comment