Magento htaccess Rewrite and Redirect
On a Magento based ecommerce site I am trying to remove index.php开发者_运维技巧 from URLs as well as 301 redirect non-www to www.
Default URL: www.example.com/index.php/super-cool-product.html
Desired Product URL: www.example.com/super-cool-product.html
Also 301 redirecting non-www to www:
example.com/super-cool-product.html to: www.example.com/super-cool-product.htmlAs well as:
www.example.com/index.html to: www.example.comThis is what I currently have:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.rejuvahealth.com/$1 [R=301,NC,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.rejuvahealth.com/$1 [R=301,NC,L]
To 301 redirect index.html:
Options +FollowSymLinks
RewriteEngine on
redirect 301 /index.html http://www.example.co.uk/
If you configure your Base URLs correctly, Magento should automatically redirect to the www. version.
For index.php rewrites, go to Configuration > Web > Use Web Server Rewrites and change to 'Yes'.
Now open your htaccess and change this line:
#RewriteBase /magento/
to this:
RewriteBase /
Assuming that your Magento folder is on the root. Be careful when using web rewrites though and ensure you back up before making any changes.
精彩评论