5

Am trying to add secure URL to my custom module - below is my config.xml sample code

<frontend>
    <secure_url>
        <scheme>/scheme/</scheme>
    </secure_url>
    <routers>
        <scheme>
            <use>standard</use>
            <args>
                <module>Companyname_Scheme</module>
                <frontName>scheme</frontName>
            </args>
        </scheme>
    </routers> 
</frontend>
<global>
    <rewrite>            
        <myschemes>
            <from><![CDATA[/myschemes\/(.*)/]]></from>
            <to><![CDATA[scheme/user/$1/]]></to>
            <complete>1</complete>
        </myschemes>
    </rewrite>

My need is to make myschemes url to access only through https:// if the user forced to load on non http i.e., http:// .

If i add secure url for myschemes then above rewrite is not working. If i enter https://www.example.com/myschemes/ as url it is redirecting to https://www.example.com/scheme/user//

How can I achieve this? Please help.

5

Interesting question, I was curious how this worked myself so I did a little digging. If you take a look at the standard router (Mage_Core_Controller_Varien_Router_Standard) you'll see that it makes a determination if a route should be secure by using _checkShouldBeSecure, which will in turn call _shouldBeSecure and this will ultimately call Mage_Core_Model_Config::shouldUrlBeSecure.

From here you can see that the way to force a URL to be secure is to declare the path so in your modules XML code. To take an example from core, which you can see in app/code/core/Mage/Customer/etc/config.xml.

<frontend>
    <secure_url>
        <customer>/customer/</customer>
    </secure_url>
</frontend>
3

I'm not sure about rewrites, but this is how you force secure urls on your own controller actions.

<frontend>
    <secure_url>
        <namespace_module_controller_action>
            /frontname/controller/action
        </namespace_module_controller_action>
    </secure_url>
</frontend>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.