设置网站404错误页面的详细步骤

时间:2026-02-12 22:56:35

1、制作一个404页面,页面自己设计即可,命名为notfound.php,上传到网站根目录。

2、打开.htaccess文件,添加代码:ErrorDocument 404 /notfound.php,然后将.htaccess文件上传到网站根目录。

3、如果.htaccess存在ErrorDocument 404 /index.php,一定要将其删除。

这种将404错误转向到网站主页的作法存在极大的风险,严重时会导致主页在搜索引擎中消失。

1、自定义404页面

制作一个404页面,命名为notfound.asp,上传到网站根目录。

2、设置404动态页面

修改应用程序根目录的设置,打开“web.config”文件编辑,加入如下内容:

<configuration>

<system.web>

<customErrors mode="On" defaultRedirect="error.asp"> 

<error statusCode=”404″redirect="notfound.asp" />

</customErrors> 

</system.web> 

</configuration>

3、修改自定义404页面

在自定义的404页面“notfound.asp”中加入:

<% Response.Status="404 NotFound" %> 

便可以保证IIS能够正确地返回“404”状态码。

© 2026 长短途
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com