location 将跟目录下某个文件夹指向2级目录

 

例如:

/caffespressos/指向/web01/caffe/

[root@web01 default]# tree web01/
web01/
└── caffe
    └── index.html

1 directory, 1 file
[root@web01 default]# cat web01/caffe/index.html 
rewrite ^/([0-9a-z]+)espressos/(.*)$ /web01/$1/$2 last;
[root@web01 default]# cat /app/server/nginx/conf/rewrite/default.conf 
#rewrite ^/index\.html /index.php last;
#if (!-e $request_filename) rewrite ^/(.*)$ index.php last;
#if (!-e $request_filename) {rewrite ^/(.*)$ /index.php last;}
#if (!-e $request_filename) {return 404;}
#if ($http_user_agent ~ Firefox) {rewrite ^(.*)?$ /nginx-Firefox/$1 break;}
#if ($http_user_agent ~ MSIE) {rewrite ^(.*)$ /nginx-MSIE/$1 break;}
#rewrite ^/(\d+)/(.+)/ /$2?id=$1 last;
#location ~ ^/(cron|templates)/ {deny all;break;}
#location ~ ^/data {deny all;}
#location ^~ /html/m.js {access_log off;root /app/www;expires 5;break;}
#rewrite ^/ck-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /ck/$1/$2/$3.html last;
rewrite ^/([0-9a-z]+)espressos/(.*)$ /web01/$1/$2 last;
[root@web01 default]# /app/server/nginx/sbin/nginx -s reload
[root@web01 default]# curl http://192.168.1.24/caffeespressos/index.html
rewrite ^/([0-9a-z]+)espressos/(.*)$ /web01/$1/$2 last;

 

posted @ 2016-08-02 13:16  bass  阅读(769)  评论(0编辑  收藏  举报