在Magento中将表单从http提交到https

时间:2022-11-23 17:56:01

Currently I would like to redirect my contacts page from http to https.

目前我想将我的联系人页面从http重定向到https。

I have managed to redirect this single page in the .htacces file by adding the following code:

我已设法通过添加以下代码在.htacces文件中重定向此单个页面:

RewriteCond %{HTTPS} off
RewriteRule ^(contacts/.*)$ https://www.domain.com/$1 [R=301,L]

This code works for my domain.

此代码适用于我的域。

The problem arrives when I click on submit. The form does not submit correct after the redirect is turned on. The message of the indexcontroller: "Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us" is not appearing and we do not receive an email. For now I turned redirecting off in the .htacces file.

当我点击提交时问题就到了。重定向打开后,表单无法正确提交。 indexcontroller的消息:“您的查询已提交并将尽快回复。感谢您与我们联系”未出现,我们也未收到电子邮件。现在我在.htacces文件中重定向了。

The contacts.xml can be found in app/design/front/base/default/layout/contacts.xml form.phtml is in app/design/frontend/base/default/template/contacts/form.phtml

contacts.xml可以在app / design / front / base / default / layout / contacts.xml中找到form.phtml在app / design / frontend / base / default / template / contacts / form.phtml中

I copied these two files in to my template in case I need to change them. I tried my utter best to find something similair, but I could not find anything that works. Please help.

我将这两个文件复制到我的模板中,以防我需要更改它们。我尽力找到类似的东西,但我找不到任何可行的东西。请帮忙。

Thanks in advance

提前致谢

1 个解决方案

#1


1  

Take a look @ Magento - Option to Remove product from cart within product view page

看看@ Magento - 选择在产品视图页面中从购物车中删除产品

config.xml

config.xml中

<config>
    <modules>
        <MagePal_Contacts>
            <version>0.6.0</version>
        </MagePal_Contacts>
    </modules>
    <frontend>
        <routers>
            <secure_url>
                <contact>/contact/</contact>
            </secure_url>
            <contacts>
                <use>standard</use>
                <args>
                    <modules>
                        <MagePal_Contacts before="Mage_Contacts">MagePal_Contacts</MagePal_Contacts>
                    </modules>
                    <frontName>contacts</frontName>
                </args>
            </contacts>
        </routers>

       ...

Then change the form action to

然后将表单操作更改为

<form action="<?php echo $this->getUrl('', array('_secure'=>true)) . 'contacts/index/post' ?>" ... 

or

要么

<form action="<?php echo $this->getUrl('contacts/index/post', array('_secure'=>true)) ?>" ... 

#1


1  

Take a look @ Magento - Option to Remove product from cart within product view page

看看@ Magento - 选择在产品视图页面中从购物车中删除产品

config.xml

config.xml中

<config>
    <modules>
        <MagePal_Contacts>
            <version>0.6.0</version>
        </MagePal_Contacts>
    </modules>
    <frontend>
        <routers>
            <secure_url>
                <contact>/contact/</contact>
            </secure_url>
            <contacts>
                <use>standard</use>
                <args>
                    <modules>
                        <MagePal_Contacts before="Mage_Contacts">MagePal_Contacts</MagePal_Contacts>
                    </modules>
                    <frontName>contacts</frontName>
                </args>
            </contacts>
        </routers>

       ...

Then change the form action to

然后将表单操作更改为

<form action="<?php echo $this->getUrl('', array('_secure'=>true)) . 'contacts/index/post' ?>" ... 

or

要么

<form action="<?php echo $this->getUrl('contacts/index/post', array('_secure'=>true)) ?>" ...