views:

146

answers:

3

Hello, all :)

I have a .htaccess file that looks like this:

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]

If I browse to my site I'm testing with, say http://www.example.com/, the index page loads correctly.

This is a Zend Framework application, and therefore it should route things out to my controllers, as it does correctly if I go to http://www.example.com/index/index or http://www.example.com/index, specifying the controller + action, and just the controller, respectively.

It also works if I do something like http://www.example.com/index/test, where I've defined another action on the index controller called test.

But if I make a TestController.php file, and attempt to go to http://example.com/test/, Apache is returning:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html><head> 
<title>404 Not Found</title> 
</head><body> 
<h1>Not Found</h1> 
<p>The requested URL /path/to/website/root/public/index.php was not found on this server.</p> 
<hr> 
<address>Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.4.6 PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch Phusion_Passenger/2.0.3 mod_perl/2.0.3 Perl/v5.8.8 Server at www.example.com Port 80</address> 
</body></html> 

Can anyone see what I've screwed up here?

Billy3

EDIT: The configuration for my site looks something like:

Alias /MySiteRoot/ "/usr/local/vsites/something/www/"
<Directory /usr/local/vsites/something/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
+1  A: 

I usually encountered this problem when mod_rewrite wasn't working.

If you have mod_rewrite already enabled, in the /etc/apache2/sites-available/yoursite.com configuration file check that the AllowOverride is set to All.

robertbasic
If mod_rewrite isn't working, why does `http://www.example.com/index/index` work correctly? Why does `/path/to/website/root/public/index.php` exist despite Apache's complaining to the contrary?
Billy ONeal
Edited my question -- AllowOverride All is listed :(
Billy ONeal
Interesting -- if I turn off the `MultiViews` option in `.htaccess` then not even `http://www.example.com/index/index` works correctly. I suspect there's some sort of permissions issue on my index.php at this point.
Billy ONeal
-rw-rw-r-- 1 subversion subversion 754 2010-01-16 22:09 index.php
Billy ONeal
I see you're using Ubuntu. Did you add the conf file for the new site under /etc/apache2/sites-available/ and then run sudo a2ensite yoursite ? Anyway, this is my virtualhost setup for a local ZF project - /etc/apache2/sites-available/zf:`<VirtualHost *:80>`` ServerAdmin webmaster@localhost`` ServerName zf`` DocumentRoot /path/to/zf/public`` <Directory /path/to/zmf>`` Options Indexes FollowSymLinks MultiViews`` AllowOverride All`` Order allow,deny`` allow from all`` </Directory>``</VirtualHost>`
robertbasic
I didn't setup the webserver.
Billy ONeal
A: 

So if I read this correctly, routing is working correctly, but not when you only specify the controller in the url.

So you have the following:

class TestController extends Zend_Controller_Action
{

    //do you have an index action???
    public function indexAction()
    {

    }

}
Travis
Yes I do. Note also that the error message is generated by Apache -- not the Zend Framework.
Billy ONeal
A: 

Turns out that if your site is not the root of the domain, you have to add a RewriteBase directive in order for things to be formatted correctly. I'm still at a loss as to why it reported the correct file beforehand, but it seems to work now.

Thanks and have a nice day :)

Billy ONeal