Khleo Posted April 7, 2013 Share Posted April 7, 2013 Salut, J'ai essayé de faire ma réécriture d'URL avec Zend_Controller_Router_Rewrite mais quelque chose semble bloquer : J'aimerai réécrire l'URL http://www.ndd.dev/interet/index/id/1/ pour http://www.ndd.dev/i/rouen/1/ Pour cela j'ai ajouté dans mon bootstrap : protected function _initRouter () { $config = new Zend_Config_Ini(APPLICATION_PATH.'/config/application.ini', APPLICATION_ENV); $router = new Zend_Controller_Router_Rewrite(); $router->addConfig($config, 'routes'); } et dans mon application.ini : routes.interet.type = "Zend_Controller_Router_Route_Regex" routes.interet.route = "/i/(.+)/([0-9]+)/" routes.interet.defaults.controller = "interet" routes.interet.defaults.action = "index" routes.interet.map.1 = "seo" routes.interet.map.2 = "id" routes.interet.reverse ="i/%s/%d/" Et mon .htaccess est le suivant : RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php Mais j'obtiens le message d'erreur suivant : Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in /www/library/Zend/Controller/Dispatcher/Standard.php:248 Stack trace: #0 /www/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /www/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 /www/htdocs/xxx/application/Bootstrap.php(8): Zend_Application_Bootstrap_Bootstrap->run() #3 /www/library/Zend/Application.php(366): Bootstrap->run() #4 /www/htdocs/xxx/html/index.php(15): Zend_Application->run() #5 {main} Next exception 'Zend_Controller_Exception' with message 'Invalid controller specified (error)#0 /www/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /www/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller in /www/library/Zend/Controller/Plugin/Broker.php on line 336 L'accès depuis http://www.ndd.dev/interet/index/id/1/ reste lui toujours disponible. Merci Link to comment Share on other sites More sharing options...
billcom Posted April 8, 2013 Share Posted April 8, 2013 Bonjour Khleo, Ne te manque t-il pas un routes.interet.defaults.module = "nomdumodule" ? Link to comment Share on other sites More sharing options...
Khleo Posted April 8, 2013 Author Share Posted April 8, 2013 Salut, oui j'ai essayé mais rien. J'ai également essayé de faire sans le .ini : $router = Zend_Controller_Front::getInstance()->getRouter(); $r = new Zend_Controller_Router_Route_Regex( "/i/([-\w]+)/(\d+)/", array('controller' => 'interet', 'action' => 'index'), array(1 => 'seo', 2 => 'id'), 'i/%s/%d/' ); $router->addRoute('interet', $r); mais là encore il essaye de trouver le controleur "i" au lieu de faire la route Link to comment Share on other sites More sharing options...
Solution Khleo Posted April 8, 2013 Author Solution Share Posted April 8, 2013 (edited) Le problème venait du regex : "i/([-\w]+)/(\d+)", au lieu de de "/i/([-\w]+)/(\d+)/", Edited April 8, 2013 by Khleo Link to comment Share on other sites More sharing options...
billcom Posted April 9, 2013 Share Posted April 9, 2013 Super problème résolu. En cherchant des solutions pour t'aider j'avais testé la solution du " / " en le rajoutant dans mes regexp du routes.ini ça ne m'a pas fait sauté la réécriture pour autant c'est bizarre. T'es sous qu'elle version de zend ? Le projet sous le quel j'ai testé est en 1.9 Link to comment Share on other sites More sharing options...
Khleo Posted April 21, 2013 Author Share Posted April 21, 2013 Désolé je n'ai pas vu ton message avant :s Je suis sous Zend 1.12 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now