Magento 1 – Problem with Rewrite for Custom Module

configurationmoduleoverridesurl-rewrite

I have created a module to disable user registration (mostly following guide here https://stackoverflow.com/questions/2959131/how-to-disable-frontend-registration-in-magento/25186894).

Unfortunately, I have a strange problem in that the rewrite works if the url is "/customer/account/create" but not if it is "/customer/account/create/" – the trailing slash causes strange behaviour, in that not only is the registration form loaded, but also a 404.

My config.xml consists of:

<?xml version="1.0"?>
<config>
<modules>
    <Company_DisableRegistration>
        <version>0.1.0</version>
    </Company_DisableRegistration>
</modules>
<global>
    <rewrite>
         <company_disableregistration_customer_account_create>
                  <from><![CDATA[#^/?customer/account/create/#]]></from>
                  <to>/disableregistration/customer_account/create</to>
             </company_disableregistration_customer_account_create>
             <company_disableregistration_customer_account_createPost>
                 <from><![CDATA[#^/?customer/account/createPost/#]]></from>
                 <to>/disableregistration/customer_account/createPost</to>
             </company_disableregistration_customer_account_createPost>
       </rewrite> 
</global>

<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <Company_DisableRegistration before="Mage_Customer">Company_DisableRegistration_Customer</Company_DisableRegistration>
                </modules>
            </args>
        </customer>
    </routers>
</frontend>
</config>

This is the first time I've attempted this sort of thing, so I'm not sure what the issue is or how to fix it.

Best Answer

I normally use something like

<global>
    <rewrite>
        <designer_url>
            <from><![CDATA[#^/author/id/$#]]></from>
            <to><![CDATA[/designer/index/index/id/$1]]></to>
            <complete>1</complete>
        </designer_url>
    </rewrite>
</global>

See $# in the end of the original URL and also the complete node.

Related Topic