Zend: How to fix the 404 Problem in a Zend Framework Project CodeUnit 23 MAR 2011

If you have a nice and shiny new Zend Framework project all set up but are still getting nasty browser 404 errors when attempting to hit URL other than the home page (instead of the expected errors dealt out by the error handler controller), the root of your problem is actually quite simple:

Your Apache mod_rewrite module is disabled and your Apache directory AllowOverride directive is not switched on.

To fix is easy enough. Locate your Apache httpd.conf configuration file and open it up. Run a search for mod_rewrite and you should find the line:

#LoadModule rewrite_module modules/mod_rewrite.so

Uncomment it in order to enable, by removing the # character from the front of the line.

Next search for AllowOverride and you should find it in one of your declarations. If it is present, change the value to All. If it isn’t, add it. (Note if you are using virtual hosts you will need to set it under the virtualhost declaration). Setting this to all means that Apache will honour local .htaccess files, which is exactly what Zend, in conjunction with mod_rewrite, depends on.

Restart Apache, and hit a non home page URL.

And now you know.

Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.