【问题标题】:Remove Trailing Slash from Magento URL从 Magento URL 中删除尾部斜杠
【发布时间】:2014-06-19 03:57:02
【问题描述】:

我知道关于这个特定问题有很多已回答的问题,但我没有找到任何特定于 Magento 的内容,我想知道更改 .htaccess 文件是否会对我的 Magento 商店产生影响。

基本上,我的导航中有链接直接进入过滤后的类别页面,因此它们看起来如下......

Example.com/hairproducts.html?manufacturer=412

但是,当我单击这些链接时,它们最终会导航到带有斜杠的 URL...

Example.com/hairproducts.html?manufacturer=412/

然后忽略过滤器并将它们带到类别页面。

为任何帮助干杯。

【问题讨论】:

  • 你能把你的代码给我这个 URL 生成的地方吗?如果它很简单,那么您可以使用 $url = rtrim($url, '/');

标签: magento url-rewriting


【解决方案1】:

我假设你有这样的 phtml 文件中生成的 url:

<?php echo $this->getUrl('hairproducts.html?manufacturer=412'); ?>

或在这样的块/页面内容中

 {{store url="hairproducts.html?manufacturer=412"}}

将它们更改为:
在 phtml 文件中:

<?php echo $this->getUrl('', array('_direct'=>'hairproducts.html', '_query'=>'manufacturer=412'); ?>

或在块/页面内容中

 {{store _direct="hairproducts.html" _query="manufacturer=412"}}

如果我猜错了,请发布您生成网址的方式。

【讨论】:

  • 这很奏效,我按照您的第二个建议将他们召集在一起。谢谢!
  • 谢谢@marius。对我来说就像一个魅力。
  • @marius 如果我们使用块文件返回带有一些查询字符串值的控制器路径怎么办。例如 return $this->getUrl('namespace/controller/filename?values=' . $value1);
  • &lt;?php echo $this-&gt;getUrl('namespace/controller/filename', array('_query'=&gt;'manufacturer=412'); ?&gt;
猜你喜欢
  • 1970-01-01
  • 2017-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-09
  • 2021-12-14
相关资源
最近更新 更多