Instantly share code, notes, and snippets.

What would you like to do?
[nginx] same domain map to different project. [Vuex(vue-route) + Laravel]
server {
listen 80;
listen [::]:80;
root /var/www/project1/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
# map project2 when url contains project2
location ~ /project2 {
alias /var/www/project2/dist;
try_files $uri $uri/ /index.html last;
# map vuejs static folder.
location /static {
alias /var/www/project2/dist/static;
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
location ~ /\.ht {
deny all;

This comment has been minimized.

aftabnaveed commented May 21, 2018

I tried this but it will download the file instead of executing it. I also heard that alias does not play well with try_files not sure if that is the problem in my case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment