2

我正在使用 PHP 5.4、Zend Studio 和 Zend-Server。

使用此 uri 时出现 404 错误:

http://localhost/MyExample/public/index.php

但是当我使用这个 uri 时,我得到了正确的页面来显示:

http://localhost/MyExample/public/index.php/

我认为这两个 uri 都是一样的。

这是 .htaccess 文件:

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]

这是 index.php 代码:

<?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();
4

1 回答 1

1

注意:添加以前的评论作为答案

这是正确的行为。键入时传递给路由器的 URIhttp://localhost/index.php包含"index.php".

由于没有路由匹配"index.php",Zend Framework 2 显示 404 错误。

使用"/"or"/index.php/"时,路由匹配到的路径为空,所以得到ZendSkeletonApplication的默认"home"路由匹配。

于 2013-02-25T14:47:38.057 回答