2013-02-24 97 views
2

我正在使用PHP 5.4,Zend Studio和Zend-Server。当URI正确时获取404错误

我得到一个404错误,当我使用这个URI:

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

但是当我使用这个URI我得到正确的页面显示:

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

,我觉得这两个乌里会是一样的。

下面是.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(); 
+0

与.htaccess有关吗? – Class 2013-02-24 04:45:02

+0

它可能是。我只是不确定是什么。 – 2013-02-24 04:45:58

+0

你能发布相关的代码,你有.htaccess或任何其他相关的网址如:php代码 – Class 2013-02-24 04:48:02

回答

2

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

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

由于没有匹配"index.php"路线,由Zend框架2.

显示404错误当使用"/""/index.php/"the path matched by the router is empty,让您得到ZendSkeletonApplication的默认"home"路由匹配。