Apache 使用错误报告 404(.htaccess 重写)

发布于 2024-12-01 17:00:35 字数 1222 浏览 1 评论 0原文

我有这个网址 http://xxxxxxxxx.com /account/session/login/redirect/%2Fhotel%2Frooms%2Findex%2Fhot_id%2F1 使用 Zend Framework (PHP)。在 .htaccess 的帮助下

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

,我得到了 404 未找到。为了确保它是Apache,我在index.php主文件启动时退出了它,apache仍然报告404。在退出之前没有执行任何php代码。

编辑

我的域的apache domlog显示了这一行

190.78.208.30 - - [25/Aug/2011:17:48:17 -0430] "GET /account/session/login/redirect/Fhotel%2Frooms%2Findex%2Fhot_id%2F1 HTTP/1.1" 404 25821 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0"

,但是error_log中没有关联的行

编辑2

如果有用,我正在运行Apache 2.2.19,PHP 5.3.6 , cpanel 11.30.2, CentOS 5.6

请注意 404 未找到。当我在执行其他任何操作之前退出index.php时,404仍然出现。我可以确定 .htaccess 正在被读取。根据建议,我放置了一个

SetEnv MYENV 1

And 显示在同一域中的 phpinfo() 中。我只是仔细检查了我的 access_log 和 error_log 并保持如上所述。

有什么想法为什么会发生这种情况吗?

I have this url http://xxxxxxxxx.com/account/session/login/redirect/%2Fhotel%2Frooms%2Findex%2Fhot_id%2F1 which uses Zend Framework (PHP). With help of a .htaccess

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

The thing is i'm getting a 404 Not found. To make sure it was Apache, i exited the index.php main file just when it starts and apache still reports 404. No code of php gets to be executed before that exit.

EDIT

The apache domlog for my domain shows this line

190.78.208.30 - - [25/Aug/2011:17:48:17 -0430] "GET /account/session/login/redirect/Fhotel%2Frooms%2Findex%2Fhot_id%2F1 HTTP/1.1" 404 25821 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0"

But there are no lines associated in the error_log

EDIT 2

If useful i'm running Apache 2.2.19, PHP 5.3.6, cpanel 11.30.2, CentOS 5.6

Print screen of 404 Not found error

Please notice the 404 not found. When i exit the index.php before executing anything else the 404 still comes up. I can be sure the .htaccess is being read. Following a recommendation i put a

SetEnv MYENV 1

And is showing up in a phpinfo() in the same domain. I just double checked my access_log and error_log and remain like described above.

Any ideas why this is happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青巷忧颜 2024-12-08 17:00:35

您确定 Apache 正在读取您的 .htaccess 文件吗?
确保作者:

  1. 您有权覆盖网站目录中的值。要实现此功能,您的 Apache 配置文件中应该包含类似以下内容:

    <目录/var/www/html>

    允许覆盖全部
    

    将 /var/www/html 替换为您的网站公共目录的路径

  2. Apache 有权读取您的 .htaccess 文件。

这样 Apache 就可以读取并应用 .htaccess 文件中的配置。

要测试它,请在 .htaccess 文件中设置一个环境变量:

SetEnv MYENV 1

然后使用 index.php 文件中的 phpinfo() 函数并搜索环境变量。如果 phpinfo() 输出中不存在环境变量,则意味着 Apache 不会解析 .htaccess 文件。

Are you sure your .htaccess file is being read by Apache?
Make sure that By:

  1. You have permissions to override values in your website directory. to have this you should have something like this in your Apache configuration file:

    <Directory /var/www/html>

    AllowOverride All
    

    </Directory>

    replace /var/www/html with the path to your website public directory

  2. Apache has permissions to read your .htaccess file.

This way Apache could read and apply configurations in your .htaccess file.

To test it, set an environment variable in your .htaccess file:

SetEnv MYENV 1

and then use the phpinfo() function in your index.php file and search for the environment variable. If the environment variable is not present in your phpinfo() output, it means the .htaccess file is not parsed by Apache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文