Zend Framework: the requested URL / my / path was not found on this server

I am completely new to the Zend Framework.

I wrote a simple web service that returns mock XML data from the Zend Framework, with a module structure like this:

AppName application configs application.ini modules default ..... api controller CatalogController.php view library public .htaccess index.php tests 

In localhost (windows 7) they work:

http: // localhost

http: // localhost / api / catalog

http: // localhost / default

on my working server (linux), I get the file "404 not found":

http://107.22.255.126/api/catalog

http://107.22.255.126/default

but it works

http://107.22.255.126

I host it on Amazon web services.

Here is my .htaccess

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] 

Here is my application.ini

 [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" //resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 0 resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.modules[] = "default" resources.modules[] = "api" resources.layout.layoutPath = APPLICATION_PATH "/layouts" resources.layout.layout = master [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1 

Here is my Bootstrap.php

 <?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initRoutes() { $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); $restRoute = new Zend_Rest_Route($front, array(), array('api')); $router->addRoute('api', $restRoute); } } ?> 

I'm out of ideas. I suspect this is due to the router in bootstraper, but cannot find any solution.

+7
source share
3 answers

Finally, the problem is that httpd.conf disables .htaccess in the directory. I added AllowOverride All to VirtualHost and it works.

like this:

 <VirtualHost *:80> DocumentRoot "var/www/html/TestMVC/public" <Directory "var/www/html/TestMVC/public"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> 

Credit @Corbin in the commentary to the question.

+15
source

I had such a problem on Ubuntu. I went to apache2.conf and installed one directory, as shown below:

 <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> 

Highlight: AllowOverride All

Remember to set apache configuration: sudo a2enmod rewrite

Then the work should work.

+4
source

yeap: http://www.phpcloud.com/help/adding-rewrite-rules-to-your-application

In step 3, I did not mention, but we did not copy the default Elefant.htaccess file to our shared folder. Instead, we are going to use the provided Zend in the PHPCloud documentation. Create a public / .htaccess file with the following contents:

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteBase / RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] php_flag zend_codetracing.trace_enable on php_flag zend_codetracing.always_dump on 
+1
source

All Articles