nginx海量文件目录hashdir

为了优化SEO,所以站点生成了静态html,但是希望目录路径好看点,所以把招聘公司的职位和公司首页生成静态文件。nginx配置文件如下,测试主要用以下这种方式

rewrite /(\d+)_(\d+)/ /$1/$2/ last;

http://mysite.com/11_1122/   访问 硬盘 /11/1122/  目录

rewrite /((\d\d)\d+)/ /$2/$1/ last;

http://mysite.com/11122/   访问 硬盘 /11/1122/  目录,取前面2个数字为一级目录

 

        rewrite_log on;
         error_log /tmp/nginx_rewrite_log.log notice;
        location ~ ^/\d+_\d+/$ {
                rewrite /(\d+)_(\d+)/ /$1/$2/ last;
        }
        location ~ ^/\d+_\d+/\d+\.html$ {
                rewrite /(\d+)_(\d+)/(.*) /$1/$2/$3 last;
        }
        location ~ ^/\d+/$ {
                rewrite /((\d\d)\d+)/ /$2/$1/ last;
        }
        location ~ ^/\d+/\d+\.html$ {
                rewrite /((\d\d)\d+)/(.*) /$2/$1/$3 last;
        }