zoukankan      html  css  js  c++  java
  • Apache服务器处理404错误页面技巧

    1.打开Apache目录查找httpd.conf文件 

    2.打开httpd.conf文件找到<Directory "    "></Directory>这对标签( " " 之间是你网站目录的绝对路径) 

    在其中任何一行加入“ErrorDocument 404 /404.html” 如下(我加到了第一行),修改后保存 

    -----------------下面是代码内容----------------- 
    <Directory />
        Options FollowSymLinks
        AllowOverride None
           ErrorDocument 404 /404.html
    </Directory>


    3.重启Apache服务,在网站根目录 E:/website/www下创建404.html,打开网站测试! 


    第二部分 Apache服务器里的单个虚拟主机的独立404页面错误设置 

    1.打开Apache目录,查找httpd.conf文件 

    2ErrorDocument 404 /404.html 指令放在那个虚拟主机的 <VirtualHost ***> 下面就可以了哦 

    3.重启Apache服务,在网站根目录 E:/website/www下创建missing.html,打开网站测试!
    -----------------下面是代码内容----------------- 
    <VirtualHost 127.0.0.1:80>
       directoryindex index.php
       ServerName x.cn
       DocumentRoot E:/host/wwwroot
       ErrorDocument 404 /missing.html
    </VirtualHost>
    注意以上两种设置只在firefox可以显示出来,ie不可以 原因是IE的一个BUG,当404页面文件小于512个字节的时候,这个404就不起作用。我的那个404恰好只有很短的一段。

    解决方法:改成URL方法。    ErrorDocument 404 http://****.com/missing.html

  • 相关阅读:
    使用vue-cli脚手架搭建简单项目框架
    总结HTML5
    导出网页内容
    vue 编写插件
    各ui库项目结构
    webpack 模块方法
    webpack4.0
    webapp优化
    http/2.0与http/1.1的区别
    setTimeout与Promise的区别
  • 原文地址:https://www.cnblogs.com/guoxianglei/p/6898335.html
Copyright © 2011-2022 走看看