When Your Zend Framework Project returns Page Not Found Errors but Everything is Configured Correctly CodeUnit 29 APR 2011

It can be pretty frustrating. Your Zend Framework project is configured 100% correctly. Mod Rewrite is enabled and working on your server, the .htaccess file is configured correctly and working, all your controllers are correctly created and specified, all with the necessary index actions, your modules are healthy, in short everything is looking 100% like all the examples taught you. Yet for some reason when you try and browse your site, you keep getting Page Not Found, Controller not specified error messages!

I had this issue recently and it was causing me to tear my hair out in frustration. My project was modularized and I was using a menu in the layout, defined in the application.ini file. Everything looked correct and on my Windows dev box all navigation seemed to be working correctly. However, copy the code over to the Ubuntu server and the navigation suddenly broke. Much frustration later, I eventually twigged as to what was wrong. The URLs contained in my menu.

As we all know, camelCase is the default way to express controller and action names in Zend. However, what we do sometimes forget, is that the default URLs are expressed in lowercase, with hyphens indicating the start of a uppercase letter.

In other words while http://myproject/ViewLogs/ may look right to you at first glance, because it matches the name of the controller perfectly, the correct URL is actually http://myproject/view-logs/.

If you remember that, then you shouldn’t go wrong. (Wish I had, to be honest).

So the simple fix was to change the way I specified my menu, from:

resources.navigation.pages.oslo.pages.sub.label = "Allowed Access"
resources.navigation.pages.oslo.pages.sub.module = "oslo"
resources.navigation.pages.oslo.pages.sub.controller = "AllowedAccess"
resources.navigation.pages.oslo.pages.sub.action = "index"

To:

resources.navigation.pages.oslo.pages.sub.label = "Allowed Access"
resources.navigation.pages.oslo.pages.sub.module = "oslo"
resources.navigation.pages.oslo.pages.sub.controller = "allowed-access"
resources.navigation.pages.oslo.pages.sub.action = "index"

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.