I'm testing a Zend project on my shared-hosting with Linux server.I keep everything inside a folder 'Zend-project' not on the server public-root (cause I have there another project!).
Problem: whenever I type:
mysite.com/zend-project/index/index
I receive the following message:
Not Found.
The requested URL /zend-project/index/index was not found on this server.
It looks like that it is not reaching index.php so I thought the problem is in the .htaccess file.The point is that it works if I type the controller name with first-letter capitalized:
mysite.com/zend-project/Index/index
edit:I tried creating a new controller 'TestController'..with a single action (called 'test')I tried to type the url with the controller lowercase (mysite.com/zend-project/test/test)and it's working!As I suspected there should be something wrong with the 'index' word itself!
Even if I type a wrong controller name (mysite.com/zend-project/qwerty/index) I can get the front controller to run with an exception generated : Invalid controller specified (qwerty)
this is the project's structure:
/public_root
/zend-project
/application
/configs
application.ini
/controllers
IndexController.php
/layouts
/views
bootstrap.php
/css
/images
/javascript
/zend-library
.htaccess
index.php
I had to tweak a little the project cause I just can't change my document_root on a shared-hosting so I edited the .htaccess to this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /zend-project/index.php [NC,L]
This is my index.php
//IDENTIFY THE LOCATION OF THE APPLICATION DIRECTORY IN RESPECT TO
//THE BOOTSTRAP FILE'S LOCATION,AND CONFIGURE PHP'S INCLUDE_PATH TO
//INCLUDE THE LIBRARY DIRECTORY'S LOCATION
echo"we are inside index.php";
define('APPLICATION_PATH',realpath(dirname(__FILE__).'/application/'));
set_include_path(APPLICATION_PATH.'/../Zend-library'.PATH_SEPARATOR.get_include_path());
/** Zend_Application */
require_once APPLICATION_PATH.'/../Zend-library/Zend/Application.php';
// Define application environment
defined('APPLICATION_ENV')|| define('APPLICATION_ENV',(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV'): 'development'));
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
This is my bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initRoutes()
{
$frontController=Zend_Controller_Front::getInstance();
$router=$frontController->getRouter();
$router->removeDefaultRoutes();
$router->setGlobalParam('lang','en');
$router->addRoute(
'lang',
new Zend_Controller_Router_Route(':lang/:controller/:action',
array('lang'=>':lang',
'module'=>'default',
'controller'=>'index',
'action'=>'index'
)
)
);
//the following route is not working remotely.
//Is working on local environment
$router->addRoute(
'langController',
new Zend_Controller_Router_Route(':controller/:action',
array(
'module'=>'default',
'controller'=>'index',
'action'=>'index'
)
)
);
$router->addRoute(
'langIndex',
new Zend_Controller_Router_Route(':lang',
array('lang'=>':lang',
'module'=>'default',
'controller'=>'index',
'action'=>'index'
)
)
);
$router->addRoute(
'langNothing',
new Zend_Controller_Router_Route('',
array(
'module'=>'default',
'controller'=>'index',
'action'=>'index'
)
)
);
}
}
where is the problem??
thanks
Luca