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(.*)$ https://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 https://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 ^(.+[^/])/$ https://%{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.
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
Yeah i recon that’ll do it.
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
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