URL规范化

有时用户输入URL时用以下三种URL均可进入主页

  1. http://domainname.com 
  2. http://www.domainname.com/index.html 
  3. http://domainname.com/index.html

 

而不是你希望的

http://www.domainname.com

这样链接的PR也会传递到所有URL,如果你用301转向把前三个URL转到

http://www.domainname.com

PR也就集中在网页http://www.domainname.com了。

 

下面介绍如何在Magento中通过URL WRITE来实现301 重定向

  1. 在Magento根目录打开.htaccess并找到下面的注释行

         <## rewrite everything else to index.php>         

          RewriteRule .* index.php [L]

         //在该行下添写以下4句
         //以下2个语句是把http://www.xxxxxxx.com/index.php重定向成http://www.xxxxxx.com
         RewriteCond %{THE_REQUEST} ^.*/index.php
         RewriteRule ^(.*)index.php$ http://www.xxxxxxx.com/$1 [R=301,L]

        //以下2句是把http://xxxxxx.com  重定向成http://www.xxxxxx.com,使之URL规则化
         RewriteCond %{http_host} ^xxxxxxx.com [NC]
         RewriteRule ^(.*)$ http://www.xxxxxxx.com/$1 [R=301,NC]
         这样设置后用户在输入http://www.xxxxxxxx.com/index.php后,会直接301至http://www.xxxxxxx.com。

    2.  进入Magento中,把BaseURL设置为http://www.xxxxxxx.com

就OK了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值