PHP header 请求返回状态值设置(301,404)
2013-01-09 17:45
375 查看
PHP header 请求返回状态值设置(301,404)
seo优化中,比较典型的一个问题是网页请求状态码的合理利用下面主要讲下经常用到的301,和404 处理
掌握PHP设置301重定向方法
一,直接使用内置函数header
header( "Location: http://tqybw.net", true, 301 );
二,使用HTTP/1.x声明301重定向
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://tqybw.net" );
注意:http://tqybw.net表示需要重定向的URL
必免重复URL
案例分析:在做天气预报网时,用户在搜索'厦门天气',其实对就的URL是http://tqybw.net/xiamen15tian/,但是两个URL是没办法一致的,所以我们可以考虑用301
1)写程序通过搜索的词得出对就的url ,厦门=>xiamen
2) 得到对应的程序后做301处理;
header( "Location: http://tqybw.net/xiamen15tian/",true,301 );
exit();
或
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://tqybw.net/xiamen15tian/" );
exit();
注意:location后的URL必须是完整的URL地址,如下:
NOT:tqybw.net/xiamen15tian/
YES:http://tqybw.net/xiamen15tian/
PHP内置header等函数资料
一,header 函数 送出 HTTP 协议的标头到浏览器,header参考资料
header ( string string [, bool replace [, int http_response_code]] )
例:PHP实现404未找到方法
header('HTTP/1.1 404 Not Found');
header("status: 404 Not Found");
include('404.php'); //404提示页
exit();
seo优化中,比较典型的一个问题是网页请求状态码的合理利用下面主要讲下经常用到的301,和404 处理
掌握PHP设置301重定向方法
一,直接使用内置函数header
header( "Location: http://tqybw.net", true, 301 );
二,使用HTTP/1.x声明301重定向
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://tqybw.net" );
注意:http://tqybw.net表示需要重定向的URL
必免重复URL
案例分析:在做天气预报网时,用户在搜索'厦门天气',其实对就的URL是http://tqybw.net/xiamen15tian/,但是两个URL是没办法一致的,所以我们可以考虑用301
1)写程序通过搜索的词得出对就的url ,厦门=>xiamen
2) 得到对应的程序后做301处理;
header( "Location: http://tqybw.net/xiamen15tian/",true,301 );
exit();
或
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://tqybw.net/xiamen15tian/" );
exit();
注意:location后的URL必须是完整的URL地址,如下:
NOT:tqybw.net/xiamen15tian/
YES:http://tqybw.net/xiamen15tian/
PHP内置header等函数资料
一,header 函数 送出 HTTP 协议的标头到浏览器,header参考资料
header ( string string [, bool replace [, int http_response_code]] )
例:PHP实现404未找到方法
header('HTTP/1.1 404 Not Found');
header("status: 404 Not Found");
include('404.php'); //404提示页
exit();
相关文章推荐
- PHP header()函数使用详细(301、404等错误设置)
- PHP header()函数使用详细(301、404等错误设置)
- IIS7.0设置404错误页,返回500状态码
- http头状态信息意议以及在php使用header设置方法
- php--------返回404状态
- Ajax跨域请求PHP header设置
- php惯用的header:301,302, Redirects, 404,及文档类型
- 如何设置404页面的返回状态码是404,而不是200
- IIS7.0设置404错误页,返回500状态码
- 404页面返回状态码应该如何设置呢
- 【转】win2008 中iis7设置404页面但返回状态200的问题解决办法
- HTTP请求返回状态码中301与302的状态码区别
- 利用Server Header tool 检查404 错误返回状态
- PHP header函数设置http报文头示例详解以及解决http返回头中content-length与Transfer-Encoding: chunked的问题
- php--------返回404状态
- php使用fsockopen请求方法,支持https/header设置/代理请求等定制
- 在用form 提交请求时,在请求处理完成后想要在JAVA后台设置返回信息状态展示到页面
- php--------返回404状态
- 利用Server Header tool 检查404 错误返回状态
- ASP.NET设置404页面返回302状态码的解决办法