3

我今晚设置了zend,默认索引页面有效(http://home.mitheren.com/399a4/public/)。从那以后,我尝试在该控制器上添加一个新动作,但我不断收到 404 错误。

这是我的 public/ 目录的 .htaccess 文件:

RewriteEngine On
RewriteBase /399a4/public
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

当我尝试访问该页面 ( http://home.mitheren.com/399a4/public/index/testing ) 时,我在 /var/log/apache2/error.log 中收到 404 错误和以下消息:

[Mon Apr 30 21:44:30 2012] [error] [client 192.168.1.254] File does not exist: /var/www/399a4/public/index.php/testing

我也尝试过重写日志记录,并在访问该页面时获得以下条目:

192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9e6020/subreq] (3) [perdir /var/www/399a4/public/] add path info postfix: /var/www/399a4/public/index.php -> /var/www/399a4/public/index.php/testing
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9e6020/subreq] (3) [perdir /var/www/399a4/public/] strip per-dir prefix: /var/www/399a4/public/index.php/testing -> index.php/testing
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9e6020/subreq] (3) [perdir /var/www/399a4/public/] applying pattern '^.*$' to uri 'index.php/testing'
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9e6020/subreq] (4) [perdir /var/www/399a4/public/] RewriteCond: input='/var/www/399a4/public/index.php' pattern='-s' => matched
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9e6020/subreq] (1) [perdir /var/www/399a4/public/] pass through /var/www/399a4/public/index.php
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9cdf80/initial] (3) [perdir /var/www/399a4/public/] add path info postfix: /var/www/399a4/public/index.php -> /var/www/399a4/public/index.php/testing
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9cdf80/initial] (3) [perdir /var/www/399a4/public/] strip per-dir prefix: /var/www/399a4/public/index.php/testing -> index.php/testing
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9cdf80/initial] (3) [perdir /var/www/399a4/public/] applying pattern '^.*$' to uri 'index.php/testing'
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9cdf80/initial] (4) [perdir /var/www/399a4/public/] RewriteCond: input='/var/www/399a4/public/index.php' pattern='-s' => matched<
192.168.1.254 - - [30/Apr/2012:21:46:54 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9cdf80/initial] (1) [perdir /var/www/399a4/public/] pass through /var/www/399a4/public/index.php

.htaccess 文件肯定正在处理中(AllowOverride 已打开,我通过添加变量并检查 php 信息进行了检查)。

更新:将规则更改为 Vytautas 建议的内容会在重写日志中为我提供以下输出:

192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ddff0/subreq] (3) [perdir /var/www/399a4/public/] add path info postfix: /var/www/399a4/public/index.php -> /var/www/399a4/public/index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ddff0/subreq] (3) [perdir /var/www/399a4/public/] strip per-dir prefix: /var/www/399a4/public/index.php/testing -> index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ddff0/subreq] (3) [perdir /var/www/399a4/public/] applying pattern '^/399a4/public/.*$' to uri 'index.php/testing'
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ddff0/subreq] (3) [perdir /var/www/399a4/public/] add path info postfix: /var/www/399a4/public/index.php -> /var/www/399a4/public/index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ddff0/subreq] (3) [perdir /var/www/399a4/public/] strip per-dir prefix: /var/www/399a4/public/index.php/testing -> index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ddff0/subreq] (3) [perdir /var/www/399a4/public/] applying pattern '^/399a4/public/.*$' to uri 'index.php/testing'
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ddff0/subreq] (1) [perdir /var/www/399a4/public/] pass through /var/www/399a4/public/index.php
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ec050/initial] (3) [perdir /var/www/399a4/public/] add path info postfix: /var/www/399a4/public/index.php -> /var/www/399a4/public/index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ec050/initial] (3) [perdir /var/www/399a4/public/] strip per-dir prefix: /var/www/399a4/public/index.php/testing -> index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ec050/initial] (3) [perdir /var/www/399a4/public/] applying pattern '^/399a4/public/.*$' to uri 'index.php/testing'
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ec050/initial] (3) [perdir /var/www/399a4/public/] add path info postfix: /var/www/399a4/public/index.php -> /var/www/399a4/public/index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ec050/initial] (3) [perdir /var/www/399a4/public/] strip per-dir prefix: /var/www/399a4/public/index.php/testing -> index.php/testing
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ec050/initial] (3) [perdir /var/www/399a4/public/] applying pattern '^/399a4/public/.*$' to uri 'index.php/testing'
192.168.1.254 - - [30/Apr/2012:21:59:14 +1000] [home.mitheren.com/sid#7f1ffd754120][rid#7f1ffd9ec050/initial] (1) [perdir /var/www/399a4/public/] pass through /var/www/399a4/public/index.php


更新 2:出于测试目的,我添加了另一个控制器(称为 test)(http://home.mitheren.com/399a4/public/test),它运行良好。这意味着我的重写规则至少可以工作吗?

更新3:解决了!我在我的第二个测试控制器上创建了更多视图,它们都工作正常。看来我的 IndexController 上的重定向只有一个问题。我不确定这是一个真正的问题还是我的问题,但现在可以了。如果其他人有更多信息,我很想听听,但这应该可以完成我的工作。

4

2 回答 2

0

public不应出现在 URL 中。您正确的网址是http://home.mitheren.com/399a4/public/index.php

于 2012-04-30T13:36:27.730 回答
0

有点解决了!我在我的第二个测试控制器上创建了更多视图,它们都工作正常。看来我的 IndexController 上的重定向只有一个问题。

我不确定这是一个真正的问题还是我的问题,但现在可以了。如果其他人有更多信息,我很想听听,但这应该可以完成我的工作。

于 2012-05-01T01:01:36.470 回答