Zend url not found

Résolu/Fermé
David - 22 mai 2011 à 21:47
 David - 22 mai 2011 à 23:55
Bonjour,

voila depuis quelques heures je suis bloqué sur ce problème. J'ai installé zend,

structure :
application
controllers
layouts
models
views
library
zend
public


Mon index.php
<?php

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
date_default_timezone_set('Europe/Paris');
session_start();
define("BASE_URL","/CCCC/");
// mise en place des répertoires et chargement des classes
set_include_path('.'
    . PATH_SEPARATOR . './library'
    . PATH_SEPARATOR . './application/models/'
    . PATH_SEPARATOR . get_include_path());


require_once 'library/Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('App_');

// Chargement de la configuration
include_once('config/sql.config.php');


// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('./application/controllers');
Zend_Layout::startMvc(array('layoutPath'=>'./application/layouts'));
/*
// run!
$frontController->dispatch();
*/

 
// init viewRenderer
Zend_Loader::loadClass("Zend_View");
$view = new Zend_View();
$viewRenderer = Zend_Controller_Action_HelperBroker::
    getStaticHelper('viewRenderer');
$viewRenderer->setView($view)
             ->setViewSuffix('phtml');
 
// call dispatcher
$frontController->dispatch();


?>


mon indexController

<?php
	// INDEX
class IndexController extends Zend_Controller_Action 
{

    function indexAction()
    {
		$this->view->monUrl = new Zend_View_Helper_BaseUrl;
		$this->view->title = "Mon titre";
    }
	
	function ajouterAction()
	{
		$this->view->title = "Ajouter un nouvel album";
	}

}


?>


Mon index.phtml
<h1><?php echo $this->escape($this->title); ?></h1>	
	<form action="/index/connexion" method="post" name="form_etape1">	
		<table width="800px">	
<p><a href="<?php echo $this->url(array('controller'=>'index','action'=>'ajouter')); ?>">Ajouter un nouvel album</a></p>
		<tr>
				<td class="celluleGauche">Login : </td><td class="celluleDroite"><input type="text" name="login" maxlength="4"></td>
			</tr>
			<tr>
				<td class="celluleGauche">Mot de Passe : </td><td class="celluleDroite"><input type="password" name="mdp" maxlength="4"></td>
			</tr>
			<tr>
				<td class="celluleDG" colspan="2"><input type="submit" name="valider" value="Valider"></td>
			</tr>
		</table>
	</form>	



Quand je clique sur le lien ou que je valide mon formulaire j'ai le message suivant :

Not Found

The requested URL /index/connexion was not found on this server.

Comment faire ?

Merci d'avance.

1 réponse

Si vous galérez comme moi voici la solution :

déja dans le fichier httpd.config de apache il faut AllowOverride à All

puis le .htaccess :

# Règles de réécriture pour Zend Framework
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ./index.php

# Sécurité : Ne pas autoriser le parcours de répertoires
Options -Indexes

# Configuration PHP
php_flag magic_quotes_gpc off
php_flag register_globals off
php_flag short_open_tag on
2