1

I have a Zend Framework application I've been working on my local machine, I've deploying it to a server but having .htaccess issues because some but not all routes fail with a "Page Not Found". Very weird that I can't access some controllers.

My .htaccess is:

RewriteBase /~user/path/to/app/public/

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 error does not occur on the local machine, only on the server. The only thing I can see that is common to the controllers that have a "Page Not Found" error on the server is that the Controller names are camel case.

Controllers that work: CustomerController, InvoiceController, StockController. Controllers that fail: SuppliersStockController, StockTypesController.

If I try to do something like 'www.route/to/app/stock-types/' or '/stock.types/' I get an "Application Error".

Bendihossan
  • 2,407
  • 5
  • 22
  • 25
  • are you sure that the views are in place and named correctly? – Songo Apr 29 '12 at 13:04
  • @Songo - Yep, as I said the whole application works on my local machine. There's no difference between my machine and the server other than the .htaccess which is just the line for the RewriteBase. – Bendihossan Apr 29 '12 at 13:13
  • presuming that there is a method StockTypesController::indexAction(), does a call to /stock-types/index also fail? [Not suggesting that the app require this; just for diagnostic purposes]. – David Weinraub Apr 29 '12 at 14:39
  • Another thought: Windows on local dev machine with *nix on the production side often accounts for different behavior, due to *nix filesystem case-sensitivity. – David Weinraub Apr 29 '12 at 14:41
  • @DavidWeinraub Correct, there is an indexAction() and calls to /stock-types/index also fails with "Application Error" (/stocktypes/index fails with "Page Not Found"). Should have said in original post, local machine is a Mac running MAMP, server is CentOS. – Bendihossan Apr 29 '12 at 14:43
  • OK, I've partially fixed the problem. By adding SetEnv APPLICATION_ENV development to the .htaccess I got a better error description. Zend is looking for a view script called "stock-types" for the StockTypeController. Renaming fixes the problem, but that doesn't explain the difference in behaviour between my local machine and the server :( – Bendihossan Apr 29 '12 at 15:43
  • what versions of PHP and ZF are on your dev machine and your server? – RockyFord Apr 30 '12 at 04:52

1 Answers1

8

You are seeing the effect of a case sensitive file system.

When you go to /stocktypes/index, ZF will look for StocktypesController.php and succeed on case insensitive systems like Mac OS X and Windows. On Linux however, it will fail.

If you go to /stock-types/index, then ZF will look for StockTypesController.php and will find it on Linux.

If ZF finds a CamelCased controller name, then it will look for a view folder with a hyphen.

Rob Allen
  • 12,643
  • 1
  • 40
  • 49