如何制作404页面

2020-05-06

404页面的作用:用户在访问一个错误页面时会跳转到首页,或者出现一个提示的页面供用户选择进入网站的某些重要页面。
404页面的制作:
一、Apache服务器的404页面设置
1、在.htaccess 文件中加入代码: ErrorDocument 404 /Error.html
2、建立一个简单的html404页面命名 Error.html
3、把 Error.html放置在网站根目录
   注意:不要将404错误直接转向到网站首页,这将导致首页不被收录;/Error.html 前面不要带主域名,否则返回的状态码是302或200状态码。
二、Windows服务器的404页面设置
      打开IIS管理器–>点击要设置自定义404的网站的属性–>点击自定义错误选项–>选中404页–>选中并打开编辑属性–>设置成 URL –> URL 里填写“/err404.html”–>按确定退出再把做好的err404.html 页面上传到网站根目录下。此处在“消息类型”中一定要选择“文件”或“默认值”,而不要选择“URL”,不然,将导致返回“200”状态码。
三、.NET网站程序的404页面制作
    打开程序根目录的 web.config文件进行编辑,在其中加入如下内容:
  <configuration>
  <system.web>
  <customErrors mode=On defaultRedirect=error.asp>
  <error statusCode=404″ redirect=notfound.asp />
  </customErrors>
  </system.web>
  </configuration>
  注:上文例中error.asp为系统默认的404页面,notfound.asp为自定义的404页面,使用时请修改相应文件名。 然后,在自定义的404页面notfound.asp中加入:
     <% Response.Status = 404 Not Found %>

--- END ---


( ! ) Warning: realpath(): open_basedir restriction in effect. File(/www/server/panel/tmp) is not within the allowed path(s): (/www/wwwroot/www.hqtweb.com/:/tmp/) in /www/wwwroot/www.hqtweb.com/wp-includes/functions.php on line 2124
Call Stack
#TimeMemoryFunctionLocation
10.723949047168shutdown_action_hook( ).../load.php:0
20.723949047168do_action( $hook_name = 'shutdown' ).../load.php:1260
30.723949047544WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:517
40.723949047544WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:348
50.724349008120wpcf7_cleanup_captcha_files( ).../class-wp-hook.php:322
60.724349008120wpcf7_init_captcha( ).../really-simple-captcha.php:555
70.724349008408ReallySimpleCaptcha->__construct( ).../really-simple-captcha.php:396
80.724449009424path_join( $base = '/www/wwwroot/www.hqtweb.com/wp-content/plugins/really-simple-captcha', $path = 'tmp' ).../really-simple-captcha.php:46
90.724449009424path_is_absolute( $path = 'tmp' ).../functions.php:2154
100.724449009424realpath( $path = 'tmp' ).../functions.php:2124