gpt4 book ai didi

.htaccess - 使用 .htaccess 重定向到 404 页面

转载 作者:行者123 更新时间:2023-12-01 00:27:02 27 4
gpt4 key购买 nike

我在我的本地主机中创建了一个名为“example”的文件夹。我在该文件夹中添加了 4 个文件。

  • index.php
  • about.php
  • .htaccess
  • 404.php

当我输入网址时 http://www.localhost/example/123 (工作正常)它将转到 404 错误页面。

当我输入网址时 http://www.localhost/example/index.php/123它没有重定向到 404 页面。示例文件夹中的 about.php 和其他 php 扩展文件也会发生同样的情况。

在我的 htaccess 文件中,我已将不存在的文件重定向到 404 页。但是对于 index.php、about.php.. 以及示例文件夹中所有具有 php 扩展名的文件没有发生这种情况。

以下是我当前的 .htaccess 文件。

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 /404.php

最佳答案

如果您想明确禁用路径信息,那么您必须使用 AcceptPathInfo directive .

AcceptPathInfo Off

关于.htaccess - 使用 .htaccess 重定向到 404 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16687883/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com