Nginx将项目配置在子目录

问题:一个完整的项目需要整合在另外一个项目中,作为一个子模块存在

有两个项目prject1 根目录/www/project1与project2 /www/project2,现在是想将probject1的目录结构变为/www/projecrt1/project2 ,然后用域名http://www.project1.com访问project1,用http://www.project1.com/pronject2访问project2

下面是nginx配置

server {
    listen 80;
    server_name msup.l;
    root   /roo/www/project1;
    index  index.php index.html;
    
    location /{
        try_files $uri $uri/ /index.php?$args;
    } 
    location /project2/{
        try_files $uri $uri/ /project2/index.php?$args;
    }     
    location ~ ^(.+\.php)(.*)$ {
        root   /root/www/project1;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

重点是:子目录project2 loccaltion的配置,以及try_files $args参数的必要性,不然pathinfo模式可能出现问题

location /project2/{
    try_files $uri $uri/ /project2/index.php?$args;
}    

posted on 2016-10-12 10:35  BigNerd  阅读(6162)  评论(0编辑  收藏  举报

导航