【问题标题】:Need to create a RewriteRule in .htaccess for a Magento website需要在 .htaccess 中为 Magento 网站创建 RewriteRule
【发布时间】:2011-09-05 17:18:18
【问题描述】:

我目前正在尝试将 RewriteRule 放入我的 Magento 网站的 .htaccess 文件中,这将允许我以以下方式编写类别 URL:

http://mydomain.com/dir/<direction>/order/<order>/<Magento category URL path>.html

我基本上想做的是使用我的 robots.txt 文件使某些类别 URL 不出现(特别是当您对类别应用不同的排序顺序时)。

假设我有以下网址:

http://mydomain.com/dir/asc/order/sales_index/footwear/mens-work-boots/motorcycle-boots.html

我希望它像 URL 一样呈现:

http://mydomain.com/footwear/mens-work-boots/motorcycle-boots.html?dir=asc&order=sales_index

我在 .htaccess 文件中的代码如下:

RewriteRule ^dir/(.*?)/order/(.*?)/(.*?)$ $3.html?dir=$1&order=$2

由于某种原因,当我把它放在那里时,我收到了 404 错误。有人可以为我指明正确的方向吗?

【问题讨论】:

    标签: apache .htaccess mod-rewrite magento


    【解决方案1】:

    我在我的服务器上试过这个

    RewriteRule ^(.*)/dir/(.*?)/order/(.*?)/(.*?)$ $4.html?dir=$2&order=$3 [R,L]
    

    当我发出请求时

    http://myserver/dir/asc/order/sales_index/footwear/mens-work-boots/motorcycle-boots.html
    

    我得到正确的重定向到

    http://yuave.dev:81/footwear/mens-work-boots/motorcycle-boots.html.html?dir=asc&order=sales_index
    

    您的请求中可能缺少 [L] 标志。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-22
      • 1970-01-01
      • 2015-08-17
      • 1970-01-01
      • 2014-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多