zoukankan      html  css  js  c++  java
  • nginx的伪静态

    1.  server {  
    2.         listen       80;  
    3.         server_name  www.xxx.com;  
    4.   
    5.         #charset koi8-r;  
    6.   
    7.         #access_log  logs/host.access.log  main;  
    8.   
    9.         location / {  
    10.            proxy_pass http://192.168.1.11:8080;  
    11.        proxy_redirect off;    
    12.        proxy_set_header Host $host;    
    13.            proxy_set_header X-Real-IP $remote_addr;    
    14.            proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;   
    15.        rewrite "/zixun/([0-9]+)(/*).html$" /zixun/$1/ last;  
    16.        rewrite "/loanProduct/([0-9]+).html$" /loanProduct/show?id=$1 last;  
    17.         
    18.         }  
    19. }  

    解释:

      rewrite "/zixun/([0-9]+)(/*).html$" /zixun/$1/ last;

    "/zixun/([0-9]+)(/*).html$"为正则表达式匹配你输入的url地址,表示/zixun/任意数字,至少出现一次,/出现0次或者多次,已.html结尾

    /zixun/$1/ last; 符合以上规则的url 转发到 /zixun/$1/到这个链接上,这个就是你实现要获得数据的链接了 ,last为后面的不进行匹配了

    如:http://www.xx.con/zixun/56.html 会把这个请求转发到 www.xx.con/zixun/56的servlet上获得数据


    Rewrite的Flags

    last - 基本上都用这个Flag。
    break - 中止Rewirte,不在继续匹配
    redirect - 返回临时重定向的HTTP状态302
    permanent - 返回永久重定向的HTTP状态301

    规则:

    一般在非根的location中配置rewrite,都是用的break;而根的location使用last比较好,因为如果配置了fastcgi或代理访问jsp文件的话,在根location下用break是访问不到


    正则表达式形式的模式匹配,如~*和~

    • ~ is case-sensitive match;
    • ‘~’表示大小写敏感的匹配
    • ~* specifies a case-insensitive match (firefox matches FireFox)
    • ‘~*’表示大小写不敏感的匹配(例如:“firefox”字符串可以成功匹配“FireFox”)
    • !~ and !~* mean the opposite, "doesn't match"
    •  !~和!~*代表跟后面的正则匹配规则相反的规则,表示不能匹配当前正则表达式规则的字符串执行后面的处理语句
    • checking for the existence of a file using the -f and !-f operators;使用-f参数以及!-f参数检测一个文件是否存在
    • checking existence of a directory using the -d and !-d operators;使用-d参数以及!-d参数检测一个目录(路径)是否存在
    • checking existence of a file, directory or symbolic link using the -e and!-e operators;使用-e以及!-e检测是否存在一个文件,一个目录或者一个符号链接。
    • checking whether a file is executable using the -x and !-x operators.使用-x以及!-x检测一个文件是否可执行

    Parts of the regular expressions can be in parentheses, whose value can then later be accessed in the$1 to $9 variables.

    正则表达式部分可以嵌套,表达式后面的部分如果用到前面的表达式可以用 $1 到$9 变量表示。

  • 相关阅读:
    C 和 C++ 的标准库分别有自己的 locale 操作方法,C 标准库的 locale 设定函数是 setlocale(),而 C++ 标准库有 locale 类和流对象的 imbue() 方法(gcc使用zh_CN.GBK,或者zh_CN.UTF-8,VC++使用Chinese_People's Republic of China.936或者65001.)
    QCache 缓存(模板类,类似于map,逻辑意义上的缓存,方便管理,和CPU缓存无关。自动获得被插入对象的所有权,超过一定数量就会抛弃某些值)
    QBuffer简单操作(被看做一个标准的可随机访问的文件,支持信号)
    Qt里的原子操作QAtomicInteger
    进程、线程、协程、例程、过程
    net Core 2.2
    如何看源码
    code review规则
    NET Core中使用Dapper操作Oracle存储过程
    实现一个Promise
  • 原文地址:https://www.cnblogs.com/beila/p/5622283.html
Copyright © 2011-2022 走看看