nginx一个域名配置多个项目问题

请教个问,下面nginx配置一个IP:192.168.88.118后面跟blog1、blog2 Laravel项目文件夹,但是访问的时候一定要是 http://192.168.88.118/blog1/,如果是http://192.168.88.118/blog1访问就失败,改怎么配置呢?

server
{
    listen 80;
    server_name 192.168.88.118;
    index index.php index.html index.htm;
    #root  /data/wwwroot/blog1/public;

    location ^~ /blog1/ {
        alias /data/wwwroot/blog1/public;
        rewrite /blog1/(.*)$ /blog1/index.php?=$1 last; break;
        #if (-d $request_filename) {
        #    rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
        #}
        location ~ \.php$ {   
            #fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME /data/wwwroot/blog1/public/index.php; 
            include fastcgi_params;
        }
    }

    location ^~ /blog2/ {
        alias /data/wwwroot/blog2/public;
        rewrite /blog2/(.*)$ /blog2/index.php?=$1 last; break;
        #if (-d $request_filename) {
        #    rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
        #}
        location ~ \.php$ {   
            #fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME /data/wwwroot/blog2/public/index.php; 
            include fastcgi_params;
        }
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      120s;
    }

    location ~ /\. {
        return 404;
    }

    location ~ .*\.(js|css)?$
    {
        expires      120s;
    }
}
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 3

^~ /blog1/ 把最后那一杠 去掉

2年前 评论
颠倒的玉石

这不就是重定向么

2年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!