Foros del Web » Programando para Internet » PHP » Zend »

Problema enrutamiento con Zend Framework

Estas en el tema de Problema enrutamiento con Zend Framework en el foro de Zend en Foros del Web. Hola, despues de desarrollar varias aplicaciones con Zend sin problemas (bueno, con problemas que he ido resolviendo... ) ahora tengo un problema que no se ...
  #1 (permalink)  
Antiguo 04/06/2010, 03:21
 
Fecha de Ingreso: junio-2010
Mensajes: 8
Antigüedad: 13 años, 11 meses
Puntos: 0
Problema enrutamiento con Zend Framework

Hola, despues de desarrollar varias aplicaciones con Zend sin problemas (bueno, con problemas que he ido resolviendo... ) ahora tengo un problema que no se como resolver.

Como siempre he desarrollado la aplicacion en local sin problemas, pero a la hora de montarla en el servidor tengo el siguiente problema.

La home de la aplicacion carga perfectamente con el nombre del dominio www.dominio.com

Sin embargo los links internos de la aplicacion www.dominio.com/controller/action no cargan (Error 404)

Si a la direccion de inicio le añado index.php (www.dominio.com/index.php) tambien carga sin problemas y aqui los links internos si funcionan. (www.dominio.com/index.php/controller/action)


Estructura de directorios:

Código:
/
/application
/application/controllers
/application/views
/application/models
/library
/public
Contenido del .htaccess

Código:
SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Como comentario adicional decir que el hosting esta en 1and1.es y que dos dominios distintos apuntaban al mismo hosting.

es decir
www.dominio.es apuntaba a la raiz del hosting /
www.dominimo.com apuntaba a la raiz del hosting /

He modificado para que los dos apunten a /public

No se si tiene algo que ver.

Mi application.ini es:

Código:
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] = 
resources.db.adapter=mysqli
resources.db.params.host=xxx
resources.db.params.username=xxx
resources.db.params.password=xxx
resources.db.params.dbname=xxx

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

Mi index.php
Código:
<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define path to application directory
defined('UPLOAD_PATH')
    || define('UPLOAD_PATH', realpath(dirname(__FILE__) . '/../filesystem'));
    
 defined('NOTICES_IMAGE_PATH')
    || define('NOTICES_IMAGE_PATH', realpath(dirname(__FILE__) . '/noticiasimg'));
    
      
    // Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();

Y mi Bootstrap

Código:
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    protected function _initDoctype()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
        $traduccion = new Zend_Translate('array', realpath(dirname(__FILE__)).'/lang/es.php', 'es');  
		Zend_Form::setDefaultTranslator($traduccion); 
    }
    protected function _initAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'Default_',
            'basePath'  => dirname(__FILE__),
        ));
        
        
        $acl=new Default_Model_ApplicationAcl();
        $auth=Zend_Auth::getInstance();
        Zend_Session::start();
        
        $fc=Zend_Controller_Front::getInstance();
        $fc->registerPlugin(new Default_Plugin_AccessCheck($acl,$auth));
        
        
        return $autoloader;
    }
}
¿Alguna idea?
  #2 (permalink)  
Antiguo 04/06/2010, 09:15
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Problema enrutamiento con Zend Framework

Verifica que tengas el modulo mod_rewrite activado e instalado, ya que por lo que dices funciona bien si usas index.php, en ese caso es el mod_rewrite que no te esta pasando las variables.

Saludos.
  #3 (permalink)  
Antiguo 04/06/2010, 17:21
 
Fecha de Ingreso: junio-2010
Mensajes: 8
Antigüedad: 13 años, 11 meses
Puntos: 0
Respuesta: Problema enrutamiento con Zend Framework

Gracias por el interes Gator.

Ya lo he solucionado, era cosa del .htacces pero el mod_rewrite estaba instalado, he tenido que cambiar el .htaccess y ponerlo así.

Código:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
Options All -Indexes
AddType x-mapp-php5 .php
AddType x-mapp-php5 .php
No se decir porqué, pero así funciona.

Etiquetas: enrutamiento, framework
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 03:00.