nginx 밴드 매개 변수 점프

4258 단어 nginx

   :https://www.baidu.com/benefit_detail?slug=bankofchina-20170320
    :https://www.test.cn/boc 
location ~ /benefit_detail {
        if ($args ~* "slug=bankofchina-20170320") {
            rewrite ^/benefit_detail /boc? permanent;
        }
        try_files $uri $uri/ /index.php?$query_string;
        }
      :
1, www.myweb.com/connect    connect.myweb.com

rewrite ^/connect$ http://connect.myweb.com permanent;

rewrite ^/connect/(.*)$ http://connect.myweb.com/$1 permanent;

2, connect.myweb.com 301   www.myweb.com/connect/ 

if ($host = "connect.myweb.com"){

rewrite ^/(.*)$ http://www.myweb.com/connect/$1 permanent;

    }

3,myweb.com    www.myweb.com

if ($host != 'www.myweb.com' ) { 

rewrite ^/(.*)$ http://www.myweb.com/$1 permanent; 

    }

4,www.myweb.com/category/123.html     category/?cd=123

rewrite "/category/(.*).html$" /category/?cd=$1 last;

5,www.myweb.com/admin/     www.myweb.com/admin/index.php?s=

if (!-e $request_filename){

rewrite ^/admin/(.*)$ /admin/index.php?s=/$1 last;

    }

6,     /index.php?s=

if (!-e $request_filename){

    rewrite ^/(.*)$ /index.php?s=/$1 last;

    }

7,www.myweb.com/xinwen/123.html   xinwen    +html      404

rewrite ^/xinwen/([0-9]+)\.html$ /404.html last;

8,http://www.myweb.com/news/radaier.html 301   http://www.myweb.com/strategy/

rewrite ^/news/radaier.html http://www.myweb.com/strategy/ permanent;

9,       404  

rewrite http://www.myweb.com/123/456.php /404.html last;

10,   htaccess

location ~//.ht {

         deny all;

     }

11,     /data/      .log.txt   ;

location ~ ^/data {

     deny all;

     }

12,       

location ~ /www/log/123.log {

      deny all;

     }

13, http://www.myweb.com/news/activies/2014-08-26/123.html     http://www.myweb.com/news/activies/123.html

rewrite ^/news/activies/2014\-([0-9]+)\-([0-9]+)/(.*)$ http://www.myweb.com/news/activies/$3 permanent;

14,nginx      rewrite

        play       play,  /admin/play      

        if ($request_filename ~ (.*)/play){ set $payvar '1';}
        if ($request_filename ~ (.*)/admin){ set $payvar '0';}
        if ($payvar ~ '1'){
                rewrite ^/ http://play.myweb.com/ break;
        }

15,http://www.myweb.com/?gid=6    http://www.myweb.com/123.html

 if ($request_uri ~ "/\?gid\=6"){return  http://www.myweb.com/123.html;}

       ,  :

* ~         

* ~*          

* !~ !~*                     

       ,  :

* -f !-f          

* -d !-d          

* -e !-e             

* -x !-x           

flag   :

* last    Apache  [L]  ,    rewrite

* break     ,          

* redirect   302                  

* permanent   301                  
nginx           :
https://blog.csdn.net/wanglei_storage/article/details/66004933
【nginx try_files   】
  try_files $uri $uri/ /index.php;   ,      http://servers.blog.ustc.edu.cn/example  ,
    $uri    /example。try_files             。       /$root/example(   $root   WordPress 
     )   ,                。  ,       example  
  。     $uri/,      /,          /$root/example/    。    ,
   fall back   try_files         /index.php,       “   ”,      
nginx      HTTP     http://servers.blog.ustc.edu.cn/index.php。       location
~ \.php$ { ... } catch  ,      FastCGI      。     URI       REQUEST_URI 
     FastCGI   WordPress    ,     URI      
[$request_uri  ]
$request_uri    url      $host     ,  http://www.baidu.com/pan/beta/test1?fid=3  url,
  www.baidu.com      ,           $request_uri   /pan/beta/test1?fid=3。
     www.baidu.com,$request_uri     / 。

if ($request_uri ~* "^/$")   url     ,        ,  www.baidu.com。
if ($request_uri ~* "test")              test     ,      ,
  www.baidu.com/pan/beta/test3

if ($request_uri ~* "^/$"){
               rewrite ^ http://kj.fnwtv.com/index.html permanent;
           }

if ($request_uri !~* "^/$") {
                rewrite ^ http://www.fnwtv.com/ permanent;
            }
【Nginx if       】
https://www.cnblogs.com/saneri/p/6257188.html
location proxy_pass    url     /     :
https://blog.51cto.com/huangzp/1954575

좋은 웹페이지 즐겨찾기