I have a page named stores and I have a following rewrite:


So the idea is for http://mystore.com/stores to go to the cms page and for http://mystore.com/store/dallas/ to go to the controller. How can I resolve this conflict?

THanks in advance

  • 1
    Unless you are using a thoroughly ancient version of Magento you should not be using global rewrites.
    – benmarks
    Commented Jul 9, 2015 at 12:40

3 Answers 3


You have three decent options besides the global rewrite you noted (it's very, very deprecated).

Possibly the easiest option is via webserver configuration (e.g. RewriteRule for Apache).

Another option would be to add a new router class with a match() method which recognizes your URL structure and can rewrite the request object just as the CMS router (Mage_Cms_Controller_Router) does:

public function match(Zend_Controller_Request_Http $request)

        ->setParam('page_id', $pageId);

    return true;

Because the request is not marked as dispatched the router loop in Mage_Core_Controller_Varien_Front::dispatch() will re-cycle and then the Standard router will match the new request structure.

Speaking of Mage_Core_Controller_Varien_Front::dispatch() - in more recent versions of Magento it is also possible through configuration to inject your own rewrite class:

public function dispatch()

$this->_getRequestRewriteController() reads the value at global/request_rewrite/model, which you can overwrite with your own value. You can extend the Mage_Core_Model_Url_Rewrite_Request class and override the rewrite() method, or you can implement your own class with a rewrite() method which detects the URL param/structure you want to use and defers to the core class.


Why do you need a rewrite for this? Your cms page should work if the URL listed in admin is "stores". Then within your module config.xml you can use the routers tag and assign a frontname as:


From this you could have a dallasAction in your controller which loads the desired content.

  • Obviously I need something different. 1. CMS page name and router frontName in your example need to be the same: both "stores" (this is why I emphasized that it is a conflict). 2. I need a rewrite, because I don't want to write an action for every single location - this is why I do rewrite, and pass "dallas" as parameter to controller index.
    – nakajuice
    Commented Jul 9, 2015 at 11:56

Instead using global rewrite, you can create the URL Rewrite in admin panel.

Navigate to

admin > catalog > Url Rewrite Management > Add Url Rewrite

Select the Custom for Url Rewrite.

Id path >> Unique id 

Requested Path >> store/dallas/

Target Path  >> /storescontroller/index/index/location/


http://mystore.com/stores will goto your cms page

http://mystore.com/stores/dallas will goto the controller

Refer this

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.