Welcome! Log In Create A New Profile

Advanced

Nginx + Laravel Rewrites

Posted by mav 
mav
Nginx + Laravel Rewrites
April 08, 2014 09:55AM
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.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 159
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready