I am using PHP 5.4, Zend Studio and Zend-Server.
I am getting an 404 error when I use this uri:
http://localhost/MyExample/public/index.php
but when I use this uri I get the right page to display:
http://localhost/MyExample/public/index.php/
I would think both of these uri would be the same.
Here is the .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
Here is the index.php code:
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Setup autoloading
require 'init_autoloader.php';
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
NOTE: Adding previous comment as answer
This is the correct behavior. The URI passed to the router when you type http://localhost/index.php
contains "index.php"
.
Since there is no route matching "index.php"
, a 404 error is displayed by Zend Framework 2.
When using "/"
or "/index.php/"
, the path matched by the router is empty, so you get the default "home"
route of the ZendSkeletonApplication is matched.