【问题标题】:Magento htaccess Rewrite and RedirectMagento htaccess 重写和重定向
【发布时间】:2011-08-26 16:36:07
【问题描述】:

在基于 Magento 的电子商务网站上,我试图从 URL 中删除 index.php,并将非 www 的 301 重定向到 www。

默认网址:www.example.com/index.php/super-cool-product.html

所需产品网址:www.example.com/super-cool-product.html

还有 301 将非 www 重定向到 www:
example.com/super-cool-product.html
到:
www.example.com/super-cool-product.html

还有:
www.example.com/index.html
到:
www.example.com

这是我目前拥有的:

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]

【问题讨论】:

  • 你没有说什么是错的,所以我认为你所做的工作是有效的。祝你成功!

标签: regex .htaccess magento


【解决方案1】:

到 301 重定向 index.html:

Options +FollowSymLinks
RewriteEngine on
redirect 301 /index.html http://www.example.co.uk/

如果您正确配置基本 URL,Magento 应该会自动重定向到 www。版本。

对于 index.php 重写,转到 Configuration > Web > Use Web Server Rewrites 并更改为“是”。

现在打开您的 htaccess 并更改此行:

#RewriteBase /magento/

到这里:

RewriteBase /

假设您的 Magento 文件夹位于根目录下。不过在使用网络重写时要小心,并确保在进行任何更改之前进行备份。

【讨论】:

  • 我无法让它工作:redirect 301 /index.html http://www.example.co.uk/ 但发现可以通过转到Catalog > URL Rewrite Management 进行设置,谢谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-04
  • 1970-01-01
  • 1970-01-01
  • 2016-09-28
  • 2013-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多