4

I'd created a module and the url for the same is something like:

http://magento.korenpub.com/designer/index/index/id/26/value/Joseph%20B.%20Soloveitchik

but I need to rewrite the url to

http://magento.korenpub.com/author/id/26/value/Joseph%20B.%20Soloveitchik

How can it be done with config.xml? I'd read this blog which describes such, but I'm unable to do it for my module.

Code from config.xml

<global>
    <rewrite>
        <designer_url>
            <from><![CDATA[#^/author/id/$#]]></from>
            <to><![CDATA[/designer/index/index/id/$1]]></to>
            <complete>1</complete>
        </designer_url>
    </rewrite>
</global>
  • What do you mean under "I'm unable to do it for my module"? Could you please add more description to your problem? – oleksii.svarychevskyi Mar 18 '14 at 11:59
  • I'd written this code <from><![CDATA[#^/author/id/$#]]></from> <to><![CDATA[/designer/index/index/id/$1]]></to> but it redirects to 404 – Mohammad Faisal Mar 18 '14 at 12:02
  • http://magento.korenpub.com/designer/index/index/id/26/value/Joseph%20B.%20Soloveitchik is live and you can check this. I need it to be shorten and replace designer with author. – Mohammad Faisal Mar 18 '14 at 12:05
  • Could you please add your config.xml to the question? – oleksii.svarychevskyi Mar 18 '14 at 12:12
  • updated my question – Mohammad Faisal Mar 18 '14 at 12:17
8

I'd been thinking it in more complicated way but its so simple

<global>
    <rewrite>
        <designer_url>
            <from><![CDATA[#^/author/id/#]]></from>
            <to><![CDATA[/designer/index/index/id/]]></to>
            <complete>1</complete>
        </designer_url>
    </rewrite>
</global>
  • Works! Magento v1.9.1. I was confused for the longest because I had from and to values switched. From is the URL you want enter in your browser, and to is the route you want to map to. – Justin Apr 14 '15 at 2:47
  • Isn't this the outdated method? – hakre Apr 27 '15 at 7:36
  • 1
    @hakre: not sure! but it worked for me what I need to be. – Mohammad Faisal Apr 27 '15 at 8:08
  • Yeah, I stand corrected. It's not outdated, I just was thinking about overloading or controller via <routers>. Nvm & thanks for quick response! – hakre Apr 27 '15 at 8:55

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.