Http状态码301和302概念简单区别及企业应用案例

来源:互联网 发布:软件中间件 编辑:程序博客网 时间:2024/06/07 06:58

Http状态码301和302的区别及企业应用案例


1、什么是301重定向?

  301重定向/跳转一般,表示本网页永久性转移到另一个地址。

    301是永久性转移(Permanently Moved),SEO常用的招式,会把旧页面的PR等信息转移到新页面;


2、什么是302重定向?

  302重定向表示临时性转移(Temporarily Moved ),当一个网页URL需要短期变化时使用。


3、301重定向与302重定向的区别

   301重定向是永久的重定向,搜索引擎在抓取新内容的同时也将旧的网址替换为重定向之后的网址。

   302重定向是临时的重定向,搜索引擎会抓取新的内容而保留旧的网址。因为服务器返回302代码,搜索引擎认为新的网址只是暂时的。


4、常见网站的应用案例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org
200
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://etiantian.org    
200
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://baidu.com
200
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://taobao.com
302
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://qq.com    
302
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://jd.com
302
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://51cto.com
301
[root@oldboy ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://sina.com.cn
301

更多http状态码知识 请浏览http://oldboy.blog.51cto.com/2561410/716294


################################################################
本文内容摘录于老男孩linux实战运维培训中心教案内容
如有转载,请务必保留本文链接及版权信息。
欢迎广到运维兄弟一起交流linux/unix网站运维技术!
网站运维交流群:114580181 45039636
老男孩 QQ:31333741  
mail:31333741@qq.com
===============================================================
老男孩linux实训联系方式
咨询:QQ:357851641 31333741 70271111 11914883  
电话:18911718229 18901398229
网站地址:http://www.etiantian.org  http://oldboy.cc
blog:http://oldboy.blog.51cto.com
################################################################

生产环境常见的HTTP状态码列表(List of HTTP status codes)为:
说明:求精不求多,有舍才有得 不一样的思维不一样的精彩。《老男孩linux实战培训》也是这个原则。

200 - OK,服务器成功返回网页 
    - Standard response for successful HTTP requests.

301 - Moved Permanently(永久跳转),请求的网页已永久跳转到新位置。
    - This and all future requests should be directed to the given.

403 - Forbidden(禁止访问),服务器拒绝请求
    - forbidden request (matches a deny filter) => HTTP 403
    - The request was a legal request, but the server is refusing to respond to it.

404 - Not Found,服务器找不到请求的页面。
    - The requested resource could not be found but may be available again in the future.

500 - Internal Server Error(内部服务器错误)
    - internal error in haproxy => HTTP 500
    - A generic error message, given when no more specific message is suitable.

502 - Bad Gateway(坏的网关),一般是网关服务器请求后端服务时,后端服务没有按照http协议正确返回结果。
    - the server returned an invalid or incomplete response => HTTP 502
    - The server was acting as a gateway or proxy and received an invalid response from the upstream server.

503 - Service Unavailable(服务当前不可用),可能因为超载或停机维护。
    - no server was available to handle the request => HTTP 503
    - The server is currently unavailable (because it is overloaded or down for maintenance).

504 - Gateway Timeout(网关超时),一般是网关服务器请求后端服务时,后端服务没有在特定的时间内完成服务。
    - the server failed to reply in time => HTTP 504
    - The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.



0 0
原创粉丝点击