Hi folks
I try to setup my nginx with multiple laravel-projects in subdirectories:
- root
-- project 1
-- project 2
For that i conf my nignx as:
// default
server {
listen 192.168.178.10:80;
server_name 192.168.178.10;
root /usr/share/nginx/www;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
rewrite_log on;
include /etc/nginx/sites-available/*.conf;
location ~ \.php$ {
include fastcgi_params;
}
}
// Project 1
rewrite ^/project1/index\.php/?(.*)$ /project1/$1 permanent;
location /project1 {
index index.php;
try_files $uri @rewriteproject1;
}
location @rewriteproject1 {
rewrite ^(.*)$ /project1/index.php/$1 last;
}
location ~ ^/project1/(index)\.php(/|$) {
include fastcgi_params;
}
// Project 2
rewrite ^/project2/index\.php/?(.*)$ /project2/$1 permanent;
location /project2 {
index index.php;
try_files $uri @rewriteproject2;
}
location @rewriteproject2 {
rewrite ^(.*)$ /project2/index.php/$1 last;
}
location ~ ^/project2/(index)\.php(/|$) {
include fastcgi_params;
}
If i open 192.168.178.10/project2, it opens index.php from project2.
If i open 192.168.178.10/project1, it opens index.php from project2.
Thanks for your help.
I try to setup my nginx with multiple laravel-projects in subdirectories:
- root
-- project 1
-- project 2
For that i conf my nignx as:
// default
server {
listen 192.168.178.10:80;
server_name 192.168.178.10;
root /usr/share/nginx/www;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
rewrite_log on;
include /etc/nginx/sites-available/*.conf;
location ~ \.php$ {
include fastcgi_params;
}
}
// Project 1
rewrite ^/project1/index\.php/?(.*)$ /project1/$1 permanent;
location /project1 {
index index.php;
try_files $uri @rewriteproject1;
}
location @rewriteproject1 {
rewrite ^(.*)$ /project1/index.php/$1 last;
}
location ~ ^/project1/(index)\.php(/|$) {
include fastcgi_params;
}
// Project 2
rewrite ^/project2/index\.php/?(.*)$ /project2/$1 permanent;
location /project2 {
index index.php;
try_files $uri @rewriteproject2;
}
location @rewriteproject2 {
rewrite ^(.*)$ /project2/index.php/$1 last;
}
location ~ ^/project2/(index)\.php(/|$) {
include fastcgi_params;
}
If i open 192.168.178.10/project2, it opens index.php from project2.
If i open 192.168.178.10/project1, it opens index.php from project2.
Thanks for your help.