首页 > 其他 > 详细

location 将多级目录下的文件转成一个文件

时间:2016-08-02 13:40:49      阅读:185      评论:0      收藏:0      [点我收藏+]

 

  /ck-135-201-7142.html 指向/ck/135/201/7142.html

[root@web01 www]# 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;
[root@web01 www]# tree default/ck/
default/ck/
└── 135
    └── 201
        └── 7142.html

2 directories, 1 file
[root@web01 www]# cat default/ck/135/201/7142.html 
bass clnking@163.com
[root@web01 www]# curl http://192.168.1.24/ck-135-201-7142.html
bass clnking@163.com

 

location 将多级目录下的文件转成一个文件

原文:http://www.cnblogs.com/bass6/p/5728812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!