Need to further shorten easy urls
I'm using the zend framework and have started setting up really easy urls. I'm aware of using a router to redirect basedupon urls to appropirate controllers and actions. However I woudl like to take it to another step.
Currently I have a controller Users with an action View. It takes a variable ID. SO the end link looks like this:
mysite.com/users/view/id/123
using a router code as below I can shorten this to
mysite.com/users/view/123
$router = new Zend_Controller_Router_Rewrite();
$router->addRoute(
'person',
new Zend_Controller_Router_Route('users/view/:id', array('controller' => 'users', 'action' => 'view'))
);
However I want to be able t开发者_如何学运维o reduce it even further to:
mysite.com/users/123
Is this even possible or am I asking too much here?
What you need is this route
$routes['users'] = new Zend_Controller_Router_Route(
'users/:id',
array('controller' => 'users', 'action' => 'view', 'id' => null)
);
NOTE Keep in mind however, that all your other actions inside Users will not be accessible with this in place unless you modify the routes again.
精彩评论