重定向到404网页或显示404消息? [英] Redirect to 404 page or display 404 message?

查看:346
本文介绍了重定向到404网页或显示404消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是cms,文件未找到的错误可以通过不同的方式处理:

I am using a cms, and file-not-found errors can be handled in different ways:


  1. 重定向,但是错误消息将显示为内容(使用带有菜单/页脚的默认布局)。

  2. 页面将被重定向到error.php 1.但地址已更改)

  3. 该页面将重定向到现有页面,例如sitemap.php

是否有相对于搜索引擎优先的方法,或者没有区别?

Is there a method to be preferred in regards to search engines, or does this make no difference?

推荐答案

如果找不到,则应发出404页面。执行重定向会导致302代码,后面紧跟一个'200 OK',这意味着有一些内容。一个404单元格显示没有文件,停止bug我。

If it's not found, then you should issue a 404 page. Doing a redirect causes a 302 code, followed by a '200 OK', implying that there IS some content. A 404 flat out says "there is no file. stop bugging me".

这样的404页面会带有正确的标题代码:

Something like this would present a 404 page with proper header code:

<?php
if ($page_not_found) {
   header('This is not the page you are looking for', true, 404);
   include('your_404_page.php');
   exit();
}

这篇关于重定向到404网页或显示404消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆