404重定向_创建一个404重定向页面

404重定向

What if a link doesn’t work on your site? Mistakes happen, after all. Pages move, filenames change… it’s even possible that the user has typed in the right domain name, but completed the page name incorrectly.

如果链接在您的网站上不起作用怎么办? 毕竟会发生错误。 页面移动,文件名更改……甚至可能用户输入了正确的域名,但错误地填写了页面名称。

The traditional response to this is the familiar "404 — Page Not Found" error, which is almost completely useless. Wouldn’t it be better to guide and inform the user? If they got close enough to get the domain right, they probably only need a nudge in the right direction to find the page they were after.

传统的解决方法是熟悉的“ 404-未找到页面”错误,几乎完全没有用。 指导并通知用户会更好吗? 如果他们之间的距离足够近以使域名正确,那么他们可能只需要在正确的方向上轻推即可找到所要访问的页面。

Fortunately, we can do just that. There is another special file, called the .htaccess file, that functions as a “trap” for occasions like this. (It can also be used to make password–protected pages, among many other functions). Note that not all web hosting providers will allow you to create or modify an .htaccess file.

幸运的是,我们可以做到这一点。 还有另一个特殊文件,称为.htaccess文件,在这种情况下它充当“陷阱”。 (除其他功能外,它还可用于制作受密码保护的页面)。 请注意,并非所有的Web托管提供商都将允许您创建或修改.htaccess文件。

The .htaccess file is a plain text file. For our purposes here, it contains a single line: ErrorDocument 404 notfound.html

.htaccess文件是纯文本文件。 对于我们这里的目的,它只包含一行:ErrorDocument 404 notfound.html

In this case, the .htaccess file is instructing the browser to find a page in the current directory called "notfound.html" in response to a 404 error. All we have to do is create the notfound.html page and upload it.

在这种情况下, .htaccess文件将指示浏览器响应404错误而在当前目录中找到一个名为"notfound.html"的页面。 我们要做的就是创建notfound.html页面并将其上传。

What should this page contain? Well, first of all, it should look somewhat like the other pages in the site. An almost–blank page will not help much more than the standard 404 browser error. Second, it should contain navigation to the most important areas of the site. A search form is often placed on the page, as is a link to the web site administrator (since if the user clicked on a link and ended up here, you should know about it). Aside from that, a 404 page can contain almost anything.

该页面应包含什么内容? 好吧,首先,它应该看起来与站点中的其他页面相似。 几乎空白的页面比标准404浏览器错误无济于事。 其次,它应该包含导航到站点最重要的区域。 通常在页面上放置搜索表单,以及指向网站管理员的链接(因为如果用户单击链接并在此处结束,则应该知道该链接)。 除此之外,404页面几乎可以包含任何内容

A custom 404 error page allows the user to find their way back into the site if they’ve fallen through a crack. It also lets them know that you care enough about them to put them back on track.

自定义的404错误页面允许用户在遇到裂缝时找到回到站点的方式。 它还使他们知道您对他们足够在意,可以使他们重回正轨。

更多资源 (Further Resources)

Donovan Hutchinson has an excellent Smashing Magaine article on how to make 404 pages more useful.

多诺万·哈钦森(Donovan Hutchinson)撰写了一篇出色的《粉碎杂志》文章,内容涉及如何使404页更有用。

翻译自: https://thenewcode.com/181/Create-A-404-Redirect-Page

404重定向

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值