Logo

Maarten Balliauw {blog}

ASP.NET, ASP.NET MVC, Windows Azure, PHP, ...

About the author

Maarten Balliauw is currently employed as a Technical Evangelist at JetBrains. His interests are mainly web applications developed in ASP.NET (C#) or PHP and the Windows Azure cloud platform.
More about me More about me
Send mail E-mail me


ASP.NET MVC Quickly Pro NuGet Subscribe to my RSS feed Follow me on Twitter! View Maarten Balliauw's profile on LinkedIn
Maarten Balliauw - MVP - Most Valuable Professional
Maarten Balliauw - ASPInsider

Search

Archive

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright Maarten Balliauw 2013


Zend Framework custom route

Today, I was once again testing the Zed Framework. One of the things I was trying to do, is creating URL's in different languages. What I did was creating a controller 'user', with the action 'edit' (i.e. www.example.com/user/edit). Now, I want this to be available in Dutch too (i.e. www.example.com/gebruiker/bewerken).

The trick is to add custom routes, which map back to the real controller and action. In my case, adding the following in my index.php did the job:

$router->addRoute('customroute1',
new Zend_Controller_Router_Route('gebruiker/bewerken',
array('controller' => 'user', 'action' => 'edit')) );

Only bad thing is that you should add this for all your actions, otherwise not all routes succeed.
Another important note is that routes are matched in reverse order. Make sure your most generic routes are defined first, and more specific routes last.


Categories: General | PHP
Comments are closed