【问题标题】:PHP Zend Framework Application needs index.php in URL to operate on CENTOSPHP Zend Framework Application 在 CENTOS 上操作需要 URL 中的 index.php
【发布时间】:2013-04-17 22:22:57
【问题描述】:

只有当我将“index.php”添加到 URL 的末尾时,该应用程序才有效。我正在使用 CENTOS。如何删除它,例如我可以转到http://server/admin/dashboard 而不是http://server/admin/index.php/dashboard。这是我的 htaccess 文件:

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

谢谢。

【问题讨论】:

  • 如果“allowOverride”设置为“all”,请检查您的 apache 配置
  • 我检查并设置为allowoverride all
  • 可能缺少“.”在 htaccess 之前? :-) .htaccess
  • 如果你去http://server/admin/dashboard你会得到一个404页面吗?如果是这样,您的 htaccess 没有被使用。
  • 是的,我得到一个 404 页面。但是,如果我去server/admin/index.php/dashboard 它可以工作。 CENTOS apache 中是否有一个设置告诉他们不要使用子目录 htaccess。在根 apache 公用文件夹中有一个通用的 htaccess

标签: php .htaccess zend-framework mod-rewrite url-rewriting


【解决方案1】:

这是我用的,如果我没记错的话,我是从Rob Allen 那里得到的:

//index.php
<?php
$_SERVER["REQUEST_URI"] = str_replace('index.php', '', $_SERVER["REQUEST_URI"]);
//rest of index.php

还有其他方法可以做到这一点,这只是我选择的一种。

【讨论】:

  • 这不起作用。在运行应用程序之前,我将它放在 index.php 页面的顶部。
猜你喜欢
  • 2013-12-21
  • 2011-06-13
  • 1970-01-01
  • 1970-01-01
  • 2011-10-10
  • 2011-04-23
  • 1970-01-01
  • 1970-01-01
  • 2011-08-30
相关资源
最近更新 更多