URL organization in Zend Framework
As you may know in ZF the urls are strictly organized. First you’ve the module, if you use modules. If there is only one module, and it is normally the default one, you omit the module name from the url. Than comes the controller name, the action name in that particular controller and than separate by / the url continues with key value pairs of the get parameters.
Of course to make this all work, you’d need to setup a simple .htaccess file just to rewrite all this to the index.php file which than parses the $_SERVER[‘REQUEST_URI’] to collect all the data he need about which controller, which action and what parameters to call.
That’s pretty simple. If you’ve the following URL /user/profile/name/john.smith you may suppose that Zend Framework calls the “user” controller, “profile” action with get parameter “name” which equals to “john.smith”. In a traditional PHP style old school URL this can look like this:
?controller=user&action=profile&name=john.smith
Why I need such long URL?
The problem is that Zend reads all this, parses it and than returns the correct output. But however not always this is what we want, right? I’d like to have custom url for the profile page. Why should I need both profile and name in my URL, I’d prefer a URL like this: /user/john.smith. Continue reading Zend Framework custom URLs