apache 403错误 Forbidden解决方法

2020-01-30 12:29:18于海丽

#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [url]http://httpd.apache.org/docs/2.2/mod/core.html#options[/url]
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>

红色部分更改为 Allow from all ,也就是所有访问允许通过。

下面是补充:

关键错误:You don't have permission to access / on this server
打开网页,结果访问提示:403错误!关闭了IE的"显示友好的HTTP错误",显示没有权限访问(You don't have permission to access / on this server)!

403 Forbidden主要原因分析

1你的IP被列入黑名单
2你在一定时间内过多地访问此网站(一般是用采集程序),被防火墙拒绝访问了
3网站域名解析到了空间,但空间未绑定此域名
4你的网页脚本文件在当前目录下没有执行权限
5在不允许写/创建文件的目录中执行了创建/写文件操作
6服务器繁忙,同一IP地址发送请求过多,遭到服务器智能屏蔽

END网站出现403 Forbidden解决办法

用以下命令修改文件夹安全属性
chcon -R -t httpd_user_content_t public_html/

所用命令解析:

ls -Z -d public_html/
    #显示文件/目录的安全语境-Z, --context
           Display  security context so it fits on most displays.  Displays only mode, user, group, security              context and file name.-d, --directory
            list directory entries instead of contents, and do not dereference symbolic links

chcon -R -t httpd_user_content_t public_html/
     #修改文件/目录的安全语境-R, --recursive
            change files and directories recursively-t, --type
            set type TYPE in the target security context

END其他解决办法:

重建dns缓存就行
在运行中输入cmd,然后输入ipconfig /flushdns即可
或HTTP 错误 403 - 限制为仅本地主机访问 Internet 服务管理器 (HTML)
HTTP 错误 403 403.1 禁止:禁止执行访问