Opencart 301重定向错误

时间:2011-11-02 03:22:49

标签: php .htaccess url redirect opencart

我读了所有可用的Q& A但我仍然没有找到任何解决方案。

我正在使用wordpress运行在线商店..现在我因支付网关选项而转移到opencart。但我有301 URL重定向问题..

http://website.com/2011/01/my-product-name/

http://website.com/my-product-name.html

我的htaccess代码:

   RewriteEngine On
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d

   #### Rewrite Code ####
   RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
   Redirect 301 ^/2011/01/my-product-name/$ http://website.com/my-product-name.html

之后我尝试将其重定向重定向到

     http://website.com/my-product-name.html/?_route_=2011/01/my-product-name/

我不知道为什么要添加?路由 = inurl和所有其他链接?

有没有可用的解决方案?

1 个答案:

答案 0 :(得分:0)

如果您想要所有2011年产品的重定向规则,可以使用

RewriteRule ^/2011/\d{2}/([^/]+)/$ index.php?_route_=$1 [L,QSA]

假设

  1. 您的所有帖子都是产品
  2. 所有帖子均来自2011年
  3. 您已在OpenCart中设置了网址重写并分配了最后一部分 (my-product-name)作为每个产品的URL别名
  4. 当然,如果有些是文章,您实际上可以使用与产品相同的方法重写到与旧Wordpress帖子具有相同内容的信息页面,方法是为其提供正确的网址别名