当前位置:
首页 >
apache 404\403错误页面跳转
发布时间:2023/12/9
18
豆豆
生活随笔
收集整理的这篇文章主要介绍了
apache 404\403错误页面跳转
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
1、全局下使用404跳转
在httpd.conf下配置跳转
| 1 | vim /usr/local/httpd/conf/httpd.conf |
| 1 2 3 4 5 6 | <Directory "/usr/local/httpd-2.4.25/htdocs"> AllowOverride None Require all granted ErrorDocument 404 /aa.jpg #配置跳转页面,注意aa文件必须在htdocs根目录下 ErrorDocument 403 /abc.jpg #403跳转 </Directory> |
#检查配置重新加载配置
| 1 | apachectl -t |
| 1 | Syntax OK |
| 1 | apachectl graceful |
#测试跳转,在没有主页文件时会跳转到403错误,显示403错误页面。在找不到文件或页面路径时会跳转到404错误,并显示404错误页面内容。
2、在虚拟主机中使用403,404跳转页面
| 1 2 3 | pwd /usr/local/httpd/conf/extra vim httpd-vhosts.conf |
| 1 2 3 4 5 6 7 8 9 10 11 | <VirtualHost *:80> ServerAdmin root@123.com DocumentRoot "/var/html/www" ServerName www.zhang.com ServerAlias zhang.com ErrorLog "logs/www-error_log" CustomLog "logs/www-access_log" common ErrorDocument 404 /404.html ErrorDocument 403 /403.html </VirtualHost> |
#错误页面必须放到DocumentRoot对应的根目录下
| 1 2 | ls /var/html/www/ 403.html 404.html index.html.ht |
#检查配置加载
apachectl -t
Syntax OK
apachectl graceful
#测试错误页面跳转成功,此处注意如果错误页面文件小于512个字节的时候,在IE浏览器下错误页面将不起作用,修复方法:
| 1 2 | ErrorDocument 404 http://****/403.html ErrorDocument 403 http://****/404.html |
后续继续更新................
本文转自 80后小菜鸟 51CTO博客,原文链接:http://blog.51cto.com/zhangxinqi/1919031
总结
以上是生活随笔为你收集整理的apache 404\403错误页面跳转的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 后台管理系统 – 权限管理
- 下一篇: nunjucks渲染富文本解析错误输出字