0

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
axiom82
  • 636
  • 1
  • 7
  • 15
  • The best solution would be to discover a configuration setting, one that would allow the system itself to redirect "controller-less" URLS to actions in the index controller. – axiom82 Dec 19 '13 at 17:10
  • Keep in mind that the router doesn't know what is a valid action or controller, so you need to give it a way to differentiate between `:module/:action` and `:module/:controller`. Otherwise, whichever has the highest priority will always match. – Tim Fountain Dec 19 '13 at 17:21
  • For full user friendly urls you should use custom routing. This way you can name you modlues/controllers/actions whatever you like and place them where you like, while still having full control over urls. – Volvox Dec 20 '13 at 09:07

0 Answers0