schema://host[:port#]/path/.../[?query-string][#anchor]

1:http协议状态
200 OK
最常见的就是成功响应状态码200了, 这表明该请求被成功地完成,所请求的资源发送回客户端

302 Found
重定向,新的URL会在response 中的Location中返回,浏览器将会自动使用新的URL发出新的Request
例如在IE中输入, http://www.google.com. HTTP服务器会返回302, IE取到Response中Location header的新URL, 又重新发送了一个Request.

304 Not Modified
代表上次的文档已经被缓存了, 还可以继续使用,
例如打开博客园首页, 发现很多Response 的status code 都是304

400 Bad Request  客户端请求与语法错误,不能被服务器所理解
403 Forbidden 服务器收到请求,但是拒绝提供服务
404 Not Found
请求资源不存在(输错了URL)
比如在IE中输入一个错误的URL, http://www.cnblogs.com/tesdf.aspx

500 Internal Server Error 服务器发生了不可预期的错误
503 Server Unavailable 服务器当前不能处理客户端的请求,一段时间后可能恢复正常
502 Bad gateway

2:http服务器控制浏览器缓存
应用场景:某手机web应用。目的:帮助消耗某运营商流量

默认情况下浏览器会对请求内容缓存 首次response 返回200 表示请求成功,当第二次在请求这个页面时候 如图片,css等会根据max生存时间及etag值判断缓存是否过期,如不过期就返回304,使用缓存
这就与消耗流量的目的相违背,为了达到目的需要在服务器发给客户端的http包头上告诉浏览器不要缓存任何内容,每次刷新都新请求

关于http具体的详细过程,cnblogs有一篇不错的文件 http://www.cnblogs.com/TankXiao/archive/2012/11/28/2793365.html 感谢,其中介绍的fiddler2是个不错的工具
然后nginx的配置也有一篇不错的文章http://blog.sina.com.cn/s/blog_5dc960cd0100hxr7.html 感谢

结合这些文章,我在nginx.conf中加了如下配置
location ~ \.(htm|html|gif|jpg|jpeg|png|bmp|ico|css|js)$
               {
                  add_header Cache-Control no-store;
                  add_header Cache-Control private;
               }
重启后,用fiddler2观察,所有请求状态返回码均是200,没有出现304,达到了效果,只是害了用户流量,amen!!!

3:nginx 出现no input file
出现这种情况大部分在用fastcgi解析php,最根本的原因是nginx传给fastcgi的参数(scritpname,script_filename)出错,导致出现弱404(跟传统404稍不同)或者no input file

前提:在nginx.conf中root指令可以定义在server,location段,如果没有没有在任何段定义root,root默认为/path/to/install/html,如/usr/local/nginx/html,nginx在遇到php文件
会交给fastcgi执行,这个转交过程需要nginx告诉fastcgi一些环境运行变量,如cgi version,server software,最重要的是要告诉fastcgi要执行的php路径,SCRIPT_FILENAME,
SCRIPT_NAME,DOCUMENT_URI,DOCUMENT_ROOT,这些变量取得root要么是默认html,要么是写在处理php的location里面的
server {
    index index.php index.html;
    root /www/;
    server_name test.com;
location /a/
{
  root  /test/;
}
location ~ .*\.php?$
 {
        try_files $uri = /50x.html;
         include fastcgi.conf;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
      }

}
此时访问http://test.com/a/index.html,实际访问路径为http://test.com/test/a/index.html 访问正常
如果你访问http://test.com/a/index.php ,不正常,此时就出现了no input file或者是弱404,因为nginx实际访问路径为http://test.com/www/a/index.php
此时www没有a这个目录,要解决此问题可以在
location ~ .*\.php?$
 {
        root /test;
         try_files $uri = /50x.html;
         include fastcgi.conf;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
   }
上述做法是不建议的,因为在处理php的时候一般不可能值处理某个目录下的php,还有一点就是location之间定义的root不能相互继承,所以 php的location
不能使用test 的location root,继承了server级别的root

建议正确配置nginx的方法

在server级别定义root,如果要引用其他目录非root目录,建议使用软连接,软连接被应用目录到root下,如下

1:URL http://test.com:8080/a/index.html 
  I):如果a目录在www目录下,那么上述URL访问html,php完全正常
  II):如果a目录不在www目录下,需要做个软连接 ln -s /path/to/a  /www/a
2:配置文件如下
server 
{
     listen 8080;
     server_name test.com; \\可以定义根据主机头的虚拟主机,主机头
     index index.php index.html;
     root  /www;
     location ~ .*\.php?$
      {
         try_files $uri = /50x.html;   
         
         include fastcgi.conf;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
      } 
}
URL URI区别 见
schema://host[:port#]/path/.../[?query-string][#anchor]

scheme               指定低层使用的协议(例如:http, https, ftp)
host                   HTTP服务器的IP地址或者域名
port#                 HTTP服务器的默认端口是80,这种情况下端口号可以省略。如果使用了别的端口,必须指明,例如 http://www.cnblogs.com:8080/
path                   访问资源的路径
query-string       发送给http服务器的数据
anchor-             锚

3:nginx proxy_pass 的proxy_hearder的一些变量
      proxy_redirect          off;
       proxy_set_header        Host $host;
       proxy_set_header        X-Real-IP $remote_addr;
       proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_pass http://19

http://blog.chinaunix.net/uid-24443760-id-3590539.html

时间: 2024-08-02 17:29:42

schema://host[:port#]/path/.../[?query-string][#anchor]的相关文章

intent-filter 之 data 「scheme, host, port, mimeType, path, pathPrefix, pathPattern」

之前一直搞不很明白 AndroidManifest.xml 中 activity 标签下的 intent-filter 中 data 标签的属性含义,今天认真看了 Dev Guide,又在网上查询了大量相关资料,现把 data 标签中的属性含义做一个总结. 一.定义  scheme, host, port, path, pathPrefix, pathPattern 是用来匹配 Intent 中的 Data Uri 的.具体规则如下: scheme://host:port/path or pat

URL query string中文字符问题

如果URL的query string中包含中文字符,在不做特殊处理的情况下通过 request.getParameter 方法是获取不到正确的信息的,这是由于下面的两个机制造成的 浏览器会自动对URL中的特殊字符进行编码,比如请求 localhost:8080/TestJSp/loginMiddle.jsp?name=测试,真正请求的URL是localhost:8080/TestJSp/loginMiddle.jsp?name=%E6%B5%8B%E8%AF%95,即浏览器自动对中文进行了基于U

Query String模块

一.对象方法 querystring.parse(str[, sep[, eq[, options]]]) //将一个 query string 反序列化为一个对象.可以选择是否覆盖默认的分割符('&')和分配符('='). querystring.stringify(obj[, sep[, eq[, options]]]) //序列化一个对象到一个 query string.可以选择是否覆盖默认的分割符('&')和分配符('=').

node.js学习第六天--Query String

1.字符串转换 Query String模块的基本介绍 Query String模块用于实现URL参数字符串与参数对象之间的互相转换,提供了“stringify”.“parse”等一些实用函数来针对字符串进行处理,通过序列化和反序列化,来更好的应对实际开发中的条件需求,对于逻辑的处理也提供了很好的帮助,下面就让我们一起来了解学习它吧! 2.序列化 stringify函数的基本用法 stringify函数的作用就是序列化对象,也就是说将对象类型转换成一个字符串类型(默认的分割符(“&”)和分配符(

使用System.IO.Combine(string path1, string path2, string path3)四个参数的重载函数提示`System.IO.Path.Combine(string, string, string, string)' is inaccessible due to its protection level

今天用Unity5.5.1开发提取Assets目录的模块,使用时采用System.IO.Path.Combine(string, string, string, string)函数进行路径生成 明明是公有函数,为何会报错,奇了怪了 有谁知道什么原因?欢迎交流 ....... ... 重新打开了一下 ,可以了.版本原因 使用System.IO.Combine(string path1, string path2, string path3)四个参数的重载函数提示`System.IO.Path.Co

hadoop报错:Does not contain a valid host:port authority

今天用sbin/start-yarn.sh启动yarn的时候,遇到下面的错误 java.lang.IllegalArgumentException: Does not contain a valid host:port authority: master at org.apache.hadoop.net.NetUtils.createSocketAddr(NetUtils.java:211) at org.apache.hadoop.net.NetUtils.createSocketAddr(N

Javascript Query String Parsing

1. URL encoding 为什么要进行URL encoding?这是因为,有些字符是不能成为URL一部分的,举个例子,比如空格符.另外,有些有特殊含义的保留字符,比如#,作为HTML锚点,用于定位到HTML文档的某个位置上:=符号在URL里用于分割URL参数的key和value. URL encoding依据以下规则: 字母(A–Z 以及 a–z),数字(0-9)以及'.','-','~'和'_'这些字符不进行编码 空格符要编码成+或者"%20" 所有其他的字符,要被编码成%HH

Does not contain a valid host:port authority: Master:8031 (configuration property 'yarn.resourcemanager.resource-tracker.address')

问题解决: 这个错误是:yarn里面的配置的格式有错误:如: <property> <name>yarn.resourcemanager.address</name> <value>Master:8032</value> </property> <property> 在<value>标签之间不能有空格.去掉空格OK. 异常堆栈如下 2014-08-30 10:20:30,171 INFO org.apache.

37.query string、_all metadata

主要知识点 1.query string基础语法 2._all metadata的理解 一.query string基础语法 1.GET /test_index/test_type/_search?q=test_field:test 查询test_field这个field(字段)中包含关键字test的所有数据. 2.GET /test_index/test_type/_search?q=+test_field:test "+"的意思就是必须包含后面的关键字test,其实加不加这个&qu