2

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();
  • something to do with .htaccess? – Class Feb 24 '13 at 04:45
  • It could be. I am just not sure what. –  Feb 24 '13 at 04:45
  • could you post relevant code that you have for .htaccess or anything else related to urls eg: php code – Class Feb 24 '13 at 04:48
  • I added the .htaccess file and the php code for php.index –  Feb 24 '13 at 04:55
  • 1
    Seems right in my opinion. There is no route matching `index.php`, so a 404 is thrown. When using `/` or `/index.php/`, the path matched by the router is empty, so you get the `home` route matched. – Ocramius Feb 24 '13 at 15:08

1 Answers1

1

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.

Ocramius
  • 23,932
  • 7
  • 97
  • 103