开发者

Magento htaccess Rewrite and Redirect

开发者 https://www.devze.com 2023-03-06 02:40 出处:网络
On a Magento based ecommerce site I am trying to remove index.php开发者_运维技巧 from URLs as well as 301 redirect non-www to www.

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.html

As well as:

www.example.com/index.html

to:

www.example.com

This 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消