Tag Archives: controller

Quick way to prevent your Zend Controller from handling a Folder Tips, Tricks and Tutorials 30 JUN 2014

If you have a folder which you need to access in the standard way without your Zend Controller handling it for you (maybe a direct file download outside of your Zend web application), the easiest and quickest way to do this is to simply create a .htaccess file inside the folder you want your Zend controller to ignore and populate it with:

RewriteEngine Off

Because .htaccess files work in a cascading manner, this will overwrite the Zend controller .htaccess file in the root folder, in essence turning off mod_rewrite and thus giving you full control over the folder in terms of Apache now serving it as how it normally would.

zend-zf-logoQuick and easy.

(There are of course loads of other ways to do this, like implementing something like “RewriteRule ^(admin|user)($|/) – [L]” – if you want to ignore folders admin or user – at the top of your main Zend .htaccess file in root, but I like the above as a particularly quick and easy way to simply ignore a specific directory!)

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.