Reputation: 370
I'm trying to make a Zend application on a shared webhost, I have no access to php.ini or anything.
Zend has been set up and working for the index controller / view. But when I try to access another controller / view by let's say "mysite.com/About" I get this error:
Not Found
The requested URL /home/vhosting/g/vhostxx/domains/mysite.com/htdocs/projectname/public/index.php was not found on this server.
My folder structure looks like this one here: http://framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair (see point 9)
The .htaccess in the root (/home/vhosting/g/vhostxx/domains/mysite.com/htdocs/projectname) looks like this:
php_value include_path "/domains/mysite.com/htdocs/www/library"
Options All -Indexes
php_flag display_errors on
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
And the .htaccess in the public folder looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
This is the index.php in the public folder:
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// 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();
And the (empty) bootstrap in the application folder:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}
The controller I'm trying to access is: projectname/application/controllers/AboutController.php Which should be accessable via mysite.com/About but instead I recieve the message stated earlier.
I really have no idea what I'm doing wrong or what I'm missing. Can anyone tell me how to solve this or how to debug this?
On a sidenote: My host automaticly translates
mysite.com/htdocs/projectname/
into
mysite.com/htdocs/www/
on ftp, not sure if that is a problem or happens when accessing it via http
Upvotes: 2
Views: 1615
Reputation: 143886
In the htaccess file in your public folder, change:
RewriteRule ^.*$ index.php [NC,L]
to include a leading slash:
RewriteRule ^.*$ /index.php [NC,L]
Apache guesses what a rewrite rule's target is, whether it's URI-path for file-path, and it looks like it is incorrectly guessing that it's a file path. You could alternatively add a base to your htaccess file:
RewriteBase /
Upvotes: 4