简体   繁体   English

如何立即将所有404链接重定向到基本HTML网站中的首页?

[英]How to instantly redirect all the 404 links to the homepage in a basic HTML site?

Instead of having a custom 404 link not found page, how can we have the clients instantly redirect to the homepage if the link is broken in a basic HTML website? 如果没有在基本HTML网站中断开链接,我们如何让客户立即重定向到首页,而不是没有找到自定义404链接的页面?

EDIT: My site is a plain HTML website with 5 pages, hosted on GoDaddy. 编辑:我的网站是一个纯HTML网站,共有5页,托管在GoDaddy上。 No server side configuration, just HTML and little CSS and JS. 没有服务器端配置,只有HTML以及少量CSS和JS。

Since you just have a static site, the simplest way to do this is with a .htaccess file. 由于您只有一个静态站点,因此最简单的方法是使用.htaccess文件。 You can redirect 404s to your homepage with this: 您可以使用以下方法将404重定向到您的首页:

ErrorDocument 404 /

您可以在错误404页面的开头使用默认的HTML重定向语法: <meta http-equiv="refresh" content="0;URL=http://yourwebsite.com/homepage.html">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM