首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当URI正确时,获取404错误

当URI正确时,获取404错误
EN

Stack Overflow用户
提问于 2013-02-24 12:37:20
回答 1查看 548关注 0票数 2

我使用的是PHP5.4、Zend Studio和Zend-Server。

当我使用这个uri时,我得到了一个404错误:

代码语言:javascript
复制
http://localhost/MyExample/public/index.php

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

代码语言:javascript
复制
http://localhost/MyExample/public/index.php/

我认为这两个uri应该是相同的。

下面是.htaccess文件:

代码语言:javascript
复制
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代码:

代码语言:javascript
复制
<?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();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-25 22:47:38

备注:将之前的评论添加为答案

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

由于没有匹配"index.php"的路由,Zend Framework2显示了404错误。

当使用"/""/index.php/"the path matched by the router is empty时,您将获得匹配的默认"home"路由的ZendSkeletonApplication

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15048724

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档