403错误处理 [英] 403 Error handling

查看:182
本文介绍了403错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a basic web application written in PHP I am looking to secure, app is located on a local web server.

在使用以下URL字符串:

When using the following url string :

的http://本地主机/测试/ index.php文件%20and%20substring(数据库(20%),1,1)=%22A%22

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

The application is outputting the following error message:

403

我想在网页中显示这样的消息提供的网址不存在

I would like the web page to display a message like "URL Provided does not exist"

我创建了一个.htaccess文件,并把它丢进包含以下目录:

I created a .htaccess file and dropped it into the directory containing the following:

输入图像的描述在这里

但我仍然面临着错误提供的文件结构,我使用的服务器和端口,这一点上通信。

But I am still facing the error providing the file structure, the server I am using and the port it is communicating on.

我是什么做错了吗?

推荐答案

有关允许的ErrorDocument 您需要设置的AllowOverride 所有。例如,这是我的虚拟主机文件:

For allowing ErrorDocument you need to set AllowOverride to All. For example, this is my virtualhost file:

<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/定制的error.html

See also https://httpd.apache.org/docs/2.4/custom-error.html

这篇关于403错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆