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;
}
}
推荐文章: