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>
7
  • What do you mean under "I'm unable to do it for my module"? Could you please add more description to your problem? Mar 18, 2014 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 Mar 18, 2014 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. Mar 18, 2014 at 12:05
  • Could you please add your config.xml to the question? Mar 18, 2014 at 12:12
  • updated my question Mar 18, 2014 at 12:17

1 Answer 1

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>
4
  • 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, 2015 at 2:47
  • Isn't this the outdated method?
    – hakre
    Apr 27, 2015 at 7:36
  • 1
    @hakre: not sure! but it worked for me what I need to be. Apr 27, 2015 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, 2015 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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