Skip to content

Instantly share code, notes, and snippets.

@martanto
Created April 7, 2020 13:16
Show Gist options
  • Save martanto/e67a3142c7034fd2e9003e437739ba3f to your computer and use it in GitHub Desktop.
Save martanto/e67a3142c7034fd2e9003e437739ba3f to your computer and use it in GitHub Desktop.
Laravel in subdirectory (Nginx)
server {
listen 80;
server_name test.test;
root /storage/web/test;
location /2018 {
alias /storage/web/test/2018/public;
try_files $uri $uri/ @nested2018;
satisfy any;
allow all;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
index index.php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location @nested2018 {
rewrite /2018/(.*)$ /2018/index.php?/$1 last;
}
location /2019 {
alias /storage/web/test/2019/public;
try_files $uri $uri/ @nested2019;
satisfy any;
allow all;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
index index.php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location @nested2019 {
rewrite /2019/(.*)$ /2019/index.php?/$1 last;
}
location / {
rewrite ^(.*)$ https://$server_name/2018$1 permanent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment