【问题标题】:Magento htaccess Search Result RewriteMagento htaccess 搜索结果重写
【发布时间】:2014-10-01 07:17:00
【问题描述】:

我们有一个使用以下内容检索搜索查询的 magento 购物车。

http://www.example.com/catalogsearch/result/?q=firstparam+otherparam+stuff

我们希望它通过以下方式提供服务: http://www.example.com/firstparam+otherparam+stuff

我们当前的规则似乎都不起作用。

RewriteCond %{QUERY_STRING} q=(.*)
RewriteRule ^/?q/(.*?)/?$ /catalogsearch/result/?q=$1 [R=301,L]

我们尝试了所有这些的各种迭代,但无济于事。

【问题讨论】:

  • + 在查询字符串中有特殊含义,它代表空格。如果你改用- 会更好。或者您可以在附加到查询字符串之前对其进行编码。
  • 您好@Stech,您找到上述解决方案了吗?请在这里分享。

标签: php .htaccess magento mod-rewrite


【解决方案1】:

试试:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+catalogsearch/result/\?q=([^&\ ]+)
RewriteRule ^ /q/%1? [L,NE,R=301]

RewriteRule ^q/(.*)$ /catalogsearch/result/?q=$1 [L,NE,QSA]

【讨论】:

  • 这提供了domain.com/q/firstparam+otherparam+stuff 但它是404s并且不运行搜索。
  • @user2196976 去http://www.domain.com/catalogsearch/result/?q=firstparam+otherparam+stuff 对你有用吗?您是否将 htaccess 文件放在站点的文档根目录中?
  • 是的,根工作正常。我怀疑这行不通,因为 Magento 会进行自定义重写以获取“/catalogsearch/result/?q=firstparam+otherparam+stuff”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多