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

如有两个项目 help 、 blog ,根目录分别为/alidata/www/help.abx.net, /alidata/www/blog.abx.net

若要用域名http://test.abx.net/help访问help,用http://test.abx.net/blog访问blog项目,可参考如下配置

server
    {
        listen 80;
        server_name test.abx.net;
        index home.html index.htm index.php default.html default.htm default.php;
        root  /alidata/www/test.abx.net/dist;

        #error_page   404   /404.html;

        location /help {
                root /alidata/www/help.abx.net;
                if (!-e $request_filename) {
                        rewrite ^(.*)$ /help/index.php$1 last;
                }

                location ~ \.php(\/.*)*$ {
                        fastcgi_split_path_info ^(.+?.php)(/.*)$;
                        fastcgi_pass   unix:/tmp/php-cgi.sock;
                        fastcgi_index  index.php;
                        fastcgi_param  SCRIPT_FILENAME   /alidata/www/help.abx.net$fastcgi_script_name;
                        include        fastcgi_params;
                }
                access_log  /alidata/log/nginx/access/help.abx.net.log;

        }
        location /blog {
                root /alidata/www/blog.abx.net;
                try_files $uri $uri/ /blog/index.php?$args;
                include enable-php.conf;
                access_log  /alidata/log/nginx/access/blog.abx.net.log;
        }
        
        location /api/ {
            proxy_pass https://localhost:3010;
         }
        
        # Deny access to PHP files in specific directory
        location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }
        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }
        location ~ /\.
        {
            deny all;
        }

        access_log  /alidata/log/nginx/access/test.abx.net.log;
    }