【发布时间】:2011-04-14 09:15:48
【问题描述】:
所以我在 CentOS 上有一个带有 LAMP 堆栈的基本 Web 服务器设置。它具有 mod_rewrite 和所有基本模块。我使用的路由在其他服务器和本地工作。但是当我尝试在新服务器上使用路由时,他们给了我一个 404 错误。现在最重要的是常规默认路由正常工作(即 /index/my-page 工作,但特殊路由 /my-page 不在此服务器上)所以我知道 mod-rewrite 正在正确触发。此外,没有带有路由名称的实际文件,因此那里没有冲突。
我的猜测是没有为路由器配置正确的东西,因为我之前以相同的方式完成了此操作并且没有问题。我想知道是否有人知道我可能错过的路由器可能需要运行的任何潜在小事情。
感谢您提供任何见解。
更新:这是我尝试过的 Rewrite htaccess 条目
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php
和(来自与我合作的另一个开发人员)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ index.php [NC,L]
除了环境的额外标记之外,还有 routes.xml:
<routes>
<home>
<route>/home</route>
<defaults>
<controller>index</controller>
<action>index</action>
</defaults>
</home>
<lifetime-solutions-annuity>
<route>/lifetime-solutions-annuity</route>
<defaults>
<controller>index</controller>
<action>lifetime-solutions-annuity</action>
</defaults>
</lifetime-solutions-annuity>
<indexed-universal-life>
<route>/indexed-universal-life</route>
<defaults>
<controller>index</controller>
<action>indexed-universal-life</action>
</defaults>
</indexed-universal-life>
<wellness-for-life>
<route>/wellness-for-life</route>
<defaults>
<controller>index</controller>
<action>wellness-for-life</action>
</defaults>
</wellness-for-life>
<join>
<route>/join</route>
<defaults>
<controller>index</controller>
<action>join</action>
</defaults>
</join>
</routes>
【问题讨论】:
-
这确实不属于ServerFault,因为路由问题可能与ZF中的路由规则有关,这肯定不是服务器配置问题。 @gokujou,你能告诉我们你的
.htaccess和你所有的路由规则吗? -
我已经在上面添加了它们。我大约 80% 肯定这是 ZF 的问题而不是服务器,但服务器可能是一种可能性。
-
你有什么版本的PHP?我在 CentOS 5.5 上有 PHP 5.1.6,远远低于 ZF 1.11 所需的 PHP 5.2.4。
标签: php zend-framework mod-rewrite routes