【发布时间】:2013-02-24 04:37:19
【问题描述】:
我正在使用 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();
【问题讨论】:
-
与 .htaccess 有什么关系?
-
有可能。我只是不确定是什么。
-
您能否发布您拥有的 .htaccess 相关代码或与 url 相关的任何其他内容,例如:php 代码
-
我添加了 .htaccess 文件和 php.index 的 php 代码
-
在我看来似乎是正确的。没有匹配
index.php的路由,所以会抛出 404。使用/或/index.php/时,路由器匹配的路径是空的,所以得到home路由匹配。
标签: php zend-framework2 zend-studio zend-server