In Zend, How Can I Route Controller-Omitted URLs To The Index Controller

70 views Asked by At

In order to have user-friendly URLs in my application, I want all URLs that call actions in the index controller to omit the controller name. For example:

/user/edit => /user/index/edit

The "index" part of the URL is unfriendly. But, I would like other controllers in the module to work as expected, such as:

/user/article/publish (does not route to /user/index/article/publish)

I am using a config file (/config/route.ini) which is loaded into the bootstrap of Zend 1.12, which basically uses Zend_Controller_Router_Route, like so:

routes.index.route = :module/:action
routes.index.defaults.controller = index
routes.index.defaults.action = index

My stumbling block is that I could not make the routes work with Zend_Controller_Router_Route. These routes should work when the page is not found. If there is an existing action in an existing controller that the URL points to, it makes sense to go there instead.

Final thought: is this even possible within Zend? Maybe I should go with the .htaccess and use mod_rewrite?

0

There are 0 answers