apache 404\403错误页面跳转
生活随笔
收集整理的這篇文章主要介紹了
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错误页面跳转的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 后台管理系统 – 权限管理
- 下一篇: jdk1.8 windows 64位 下