【发布时间】:2013-07-26 14:58:14
【问题描述】:
我网站的所有页面都使用url重写,例如:
http://localhost/inventory/orga/organization/manage
但是 2 个 url 不起作用,并且都在 URL 中包含“索引”,所以我怀疑这是原因:
http://localhost/inventory/index
http://localhost/inventory/index/home
这些 URL 导致 404 未找到。
该网站是一个 PHP 应用程序。这是 .htaccess 文件:
RewriteEngine on
RewriteBase /inventory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
我检查了 Apache 配置,没有发现任何问题。 DirectoryIndex 是 Ubuntu 的默认索引(index.php、index.html、...但不仅仅是index)。
知道为什么以及如何解决这个问题吗?
【问题讨论】:
-
我没有看到任何问题,我测试了相同的代码,索引没有任何问题
-
您的应用程序可能会返回 404,因为任何不存在的文件都会被重写到您的 index.php 中,除非您没有包含其他重写规则
-
@Anigel 所以我不应该有 404。无论如何,所有其他页面都可以正常工作,Akam 也对其进行了测试。
-
重写规则将其发送到您的应用程序。您的应用程序中的某些内容返回 404 而不是重写规则
-
@Anigel 好的,我明白你的意思,但我 100% 确定应用程序方面没有问题。我切换PC并重新安装了系统,现在问题出现了。我使用与所有其他同事完全相同的代码,并且该应用程序在生产中运行良好。我怀疑 Apache 配置(不是重写规则或应用程序本身)。
标签: php apache zend-framework url-rewriting