如何在 Magento 中获取商店安全 URL?

发布于 2024-10-04 03:39:28 字数 222 浏览 7 评论 0原文

我在 Magento 中有一个表单,显示在不安全的 URL (http) 上,但我需要它提交到安全 URL (https)。

我显示当前使用以下代码的 URL:

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)

我假设我需要将 URL_TYPE_WEB 更改为其他内容。有谁知道那是什么?

I have a form in Magento that is displayed over the insecure URL (http) but I need it to submit to the secure URL (https).

I display the URL I currently use the following code:

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)

I am assuming I need to change the URL_TYPE_WEB to something else. Does anyone know what that something else is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

内心荒芜 2024-10-11 03:39:28

你试过这个吗?

Mage::getUrl('',array('_secure'=>true))

我相信这会让你获得基本的安全网址。

Mage::getUrl('customer/account/login',array('_secure'=>true))

将带您进入登录页面。换句话说,

Mage::getUrl('module/controller/action',array('_secure'=>true))

将带您到达您想要的任何页面,只需将“模块/控制器/操作”替换为适当的组合即可。

编辑——修正错别字

Have you tried this?

Mage::getUrl('',array('_secure'=>true))

I think that gets you the base secure url, I believe.

Mage::getUrl('customer/account/login',array('_secure'=>true))

Will get you to the login page. In other words,

Mage::getUrl('module/controller/action',array('_secure'=>true))

Will get you to any page you want, just substitute 'module/controller/action' for the appropriate combo.

Edit -- Fixed Typos

月竹挽风 2024-10-11 03:39:28

http://blog.geekslikeshinythings.com/2014/12/ magento-force-secure-urls-https-on-all.html

这适用于 Mageno 1.9.1
使用您的 app/etc/config.xml 文件

<?xml version="1.0"?>
<config>
  <frontend>
    <secure_url>
      <all>/</all>
    </secure_url>
  </frontend>
</config>

如果用户使用 https,这将强制所有 url 重写(创建为)为 https。

http://blog.geekslikeshinythings.com/2014/12/magento-force-secure-urls-https-on-all.html

this works in Mageno 1.9.1
use your app/etc/config.xml file

<?xml version="1.0"?>
<config>
  <frontend>
    <secure_url>
      <all>/</all>
    </secure_url>
  </frontend>
</config>

If user is using https, this should force all urls to rewrite (created as) to https.

尤怨 2024-10-11 03:39:28

用途:

    Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);

读取在admin中设置的magento中的配置值。

Use:

    Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);

to read the the configuration value inside magento that has been set inside admin.

命硬 2024-10-11 03:39:28

这对我有用

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));

例如:

如果您使用 http 浏览,那么

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// http://dominio.com/customer/account/loginPost

如果您使用 https 浏览,那么

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// https://dominio.com/customer/account/loginPost

this worked to me

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));

For example:

if you browsing with http then

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// http://dominio.com/customer/account/loginPost

if you browsing with https then

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// https://dominio.com/customer/account/loginPost
樱娆 2024-10-11 03:39:28

您可以在代码中执行此操作,也可以从 xml 中执行此操作。

例如,如果您想为结帐页面设置 https,则必须在自定义 config.xml 中添加以下代码:

<code>
        <secure_url>
                <checkout_onepage>/checkout/onepage</checkout_onepage>
                <checkout_multishipping>/checkout/multishipping</checkout_multishipping>
        </secure_url>
</code>

Magento 有一个用于结帐的 https 的默认功能,因此您可以对其他页面执行相同的操作,例如对于客户页面:

<code>
        <secure_url>
                <customer>/customer/</customer>
        </secure_url>
</code>

希望对您有所帮助。

You can do this in code and also from xml.

For example, if you want to set https for the check out page then you have to add the below code in your custom config.xml:

<code>
        <secure_url>
                <checkout_onepage>/checkout/onepage</checkout_onepage>
                <checkout_multishipping>/checkout/multishipping</checkout_multishipping>
        </secure_url>
</code>

Magento has a default feature for https for check out so you can do the same thing for other pages like for the customer page:

<code>
        <secure_url>
                <customer>/customer/</customer>
        </secure_url>
</code>

I hope it'll help you.

眼角的笑意。 2024-10-11 03:39:28

尝试过这对我有用。

法师::getUrl('',array('_secure'=>true))

添加此代码后,最终如下所示

IWD.ProductVideoView.urlGetVideo = "<?php echo Mage::getUrl('iwd_productvideo/player/getvideo/',array('_secure'=>true)); ?>?isAjax=true";

Tried this its working for me.

Mage::getUrl('',array('_secure'=>true))

After added this code finally its look like below

IWD.ProductVideoView.urlGetVideo = "<?php echo Mage::getUrl('iwd_productvideo/player/getvideo/',array('_secure'=>true)); ?>?isAjax=true";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文