Zend Framework - how to rewrite URL for SEO url
I got a site on Zend Framework (im total noob in Zend). For example, I would like to make a single url " " so that it looks like " ". How do I achieve this in Zend? I'm new to Zend and Apache server. Where do I rewrite in Zend? I need a static url someebsite.com/page/about to rewrite to someebsite.com/about-product
And the last question: where do I usually create rewrites? does it depend on the level / technology?
source to share
In your bootstrap, you will need to set up some "routes". So if your bootstrap ends up something like this:
$frontController = Zend_Controller_Front::getInstance(); $frontController->dispatch();
you can just add some route definitions like:
$frontController = Zend_Controller_Front::getInstance(); $router = $frontController->getRouter(); $router->addRoute( 'mylovelyroute', new Zend_Controller_Router_Route_Static( 'for-fun-link', array( 'controller' => 'test', 'action' => 'about' ) ) ); $router->addRoute( 'myotherroute', new Zend_Controller_Router_Route_Static( 'about-product', array( 'controller' => 'page', 'action' => 'about' ) ) ); $router->addRoute( 'justonemore', new Zend_Controller_Router_Route_Static( 'another/longer/path', array( 'controller' => 'mycontroller', 'action' => 'myaction', 'someparameter' => 'foo' ) ) ); $frontController->dispatch();
The first parameter
is just a unique name.
takes the path you want to capture, then an array of parameters, including the controller and action (and module, if applicable).
If you want to add complexity, you can load routes from the database, or start using more dynamic routes. The docs here are a helpful next step: http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.standard
source to share