0

我在 Magento 静态块中添加了一些链接,例如:

    <a title="Click here for more information" href="{{store_url=about-us}" target="_self">About Us</a>

这似乎工作得很好,但是一旦我使用 HTTPS,链接就会保持 http:// 格式。有没有办法让这些也自动更改为 HTTPS?

一些建议将不胜感激。

4

1 回答 1

0

默认情况下,这是 Magento 的行为方式。

尝试使用以下代码创建 links.phtml 文件

if(Mage::app()->getStore()->isCurrentlySecure()){
    $url = Mage::getUrl('about-us', array('_secure'=>true));
     //$url = Mage::getUrl('',array('_secure'=>true) . 'about-us'; // if above code doesn't work try this
}
else{
     $url = Mage::getUrl('about-us');
}

echo '<a title="Click here for more information" href="'. $url .'" target="_self">About Us</a>';

然后在你的静态块中

{{block type="core/template" template="path/to/file/links.phtml"}}

使用 apache rewrite 会将页面重定向到 https,但查看源代码时的链接仍然没有 https

如果您在服务器上启用了缓存,请仔细检查以确保它不缓存一个版本....如果缓存,那么您需要将块类型(核心/模板)更改为不缓存的)

于 2012-10-04T05:51:01.563 回答