【问题标题】:403 Error handling403错误处理
【发布时间】:2016-02-14 05:49:30
【问题描述】:

我有一个用 PHP 编写的基本 Web 应用程序,我希望保护该应用程序位于本地 Web 服务器上。

当使用以下 url 字符串时:

http://localhost/test/index.php%20and%20substring(database(%20),1,1)=%22a%22

应用程序正在输出以下错误消息:

我希望网页显示一条消息,例如“提供的 URL 不存在”

我创建了一个 .htaccess 文件并将其放入包含以下内容的目录中:

但我仍然面临提供文件结构、我正在使用的服务器以及它正在通信的端口的错误。

我做错了什么?

【问题讨论】:

    标签: php .htaccess url-routing http-status-code-403


    【解决方案1】:

    要允许ErrorDocument,您需要将AllowOverride 设置为All。例如,这是我的 virtualhost 文件:

    <VirtualHost *:80>
        ServerName localhost
        ServerAlias php.local
        ServerAlias sub.php.local
    
        LogLevel debug
    
        DocumentRoot /var/www/projects/php
    
        <Directory /var/www/projects/php>
        DirectoryIndex index.php
            AllowOverride All
            Order Allow,Deny
            Allow from All
        </Directory>
    
    </VirtualHost>
    

    您还可以将AllowOverride 设置为FileInfo 以使用ErrorDocument。

    另见https://httpd.apache.org/docs/2.4/custom-error.html

    【讨论】:

      猜你喜欢
      • 2019-01-13
      • 2012-08-06
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 1970-01-01
      • 1970-01-01
      • 2017-08-06
      • 2016-12-30
      相关资源
      最近更新 更多