I googled alot but I did not find any answers. I wanted to test the
MVC system, but I'm always getting http error 404 when I try to access
http://local-mysite/unknownctrl
Backgrounds:
PHP 5.1.6
Zend Framework 0.6.0
Apache 2.2.* (mod_rewrite enabled/loaded)
local-mysite is (in /etc/httpd/conf/httpd.conf)
<VirtualHost *:80>
ServerName local-mysite
DocumentRoot /var/www/html/mysite
</VirtualHost>
local-mysite is defined in /etc/hosts so that my local DNS knows it.
127.0.0.1 local-mysite localhost
the virtualhost directive is working, no problem with that. I put a
phpinfo file at the documentroot, and the $_SERVER vars are OK.
at the documentroot i have the following dirs & files
app/
app/controllers (contains "IndexController.php")
app/models
app/viewers
index.php
.htaccess
the content of .htaccess is
Code: Select all
RewriteEngine On
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.phpCode: Select all
<?php
$_include_path=get_include_path();
$_include_path.=PATH_SEPARATOR.'/usr/share/ZendFramework/library';
$_include_path.=PATH_SEPARATOR.'/usr/share/Smarty';
if(set_include_path($_include_path)==FALSE){
echo "Error: unable to set include path\n";
exit(1);
}
require_once 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
Zend::loadClass('Zend_Controller_RewriteRouter');
Zend::loadClass('Zend_Controller_Action');
Zend::loadClass('Zend_Controller_Request_Http');
$request=new Zend_Controller_Request_Http();
$base_url = dirname($_SERVER['PHP_SELF']);//substr($_SERVER['PHP_SELF'], 0, -9);
$request->setBaseUrl($base_url);
$router=new Zend_Controller_RewriteRouter();
//Zend_Controller_Front::run('./app/controllers');
try{
$front=Zend_Controller_Front::getInstance();
$front->throwExceptions(true);
$front->returnResponse(true);
$front->setControllerDirectory('./app/controllers');
$front->setRouter($router);
$response=$front->dispatch($request);
echo $response;
}catch(Zend_Controller_Exception $e){
echo $e->getMessage();
}
?>i've got a message from IndexController::indexAction (it's the same
content than the manual's, a basic echo "hello i'm indexcontroller")
but when i go to http://local-mysite/unknownctrler
i just have a 404 error telling me the file is not found ??? i
expected that the .htaccess would have redirected me to index.php.
thanks for reading this far
best regards,