Home > php教程 > php手册 > php header中301/404跳转要注意事项详解

php header中301/404跳转要注意事项详解

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-02 09:14:30
Original
1120 people have browsed it

如果你的网页出现301或404对于用户体验来讲是一个非常严重的问题了,所以我们在做php header301或404时就必须小心再小心了,正同我来看看。

301跳转

header('HTTP/1.1 301 Moved Permanently');   
header('Location: http://www.abc.com/aaa/');   
exit();
Copy after login

不要漏了header('HTTP/1.1 301 Moved Permanently'); 不然返回不了301

404错误页面

header("HTTP/1.1 404 Not Found");
Copy after login

如果上面的不起作用,可以试试下面的:

header("Status: 404 Not Found");
Copy after login

所以为了万无一失,可以两句都写上:

header("HTTP/1.1 404 Not Found"); 
header("Status: 404 Not Found");
Copy after login

小提示,

如果写好代码之后我们必须使用站长工具来测试一下返回的状态是不是我们想要的哦。


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template