Magento的标准URL

时间:2015-10-21 09:35:27

标签: .htaccess magento

Magento的规范网址:目前网站有一个网页有多个网址。

需要使用301重定向重定向给定网址,例如:

http://www.example.com/index.php/
http://www.example.com/
http://example.com/index.php/
http://example.com/

http://www.example.com/

需要它用于搜索引擎优化目的,否则搜索引擎会将每个页面视为重复。

2 个答案:

答案 0 :(得分:1)

您可以按照以下步骤进行操作

  • 启用apache mode_rewrite
  • 系统中的
  • http://www.example.com/ - >配置 - >常规 - >网络 - >不安全和安全
  • 系统 - >中启用搜索引擎优化配置 - >网络 - >搜索引擎优化,选择
  • 检查.htaccess中是否RewriteBase /。如果DOCUMENT_ROOT是另一个目录而不是RewriteBase /MAGENTO_DIR/

或者,您也可以重定向到虚拟主机

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / http://www.example.com/
</VirtualHost>

apache redirect from non www to www可能对您有所帮助

答案 1 :(得分:1)

请按照步骤

    系统中的
  • http://www.example.com/ - >配置 - &gt;常规 - &gt;网络 - &gt;不安全和安全
  • 系统 - &gt;中启用搜索引擎优化配置 - &gt;网络 - &gt;搜索引擎优化,选择

现在,在.htaccess文件中添加以下代码,从url中删除index.php

RewriteBase /
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

现在在.htaccess文件中添加以下代码,以便始终重定向到http://www

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

由于