Skip to content

Instantly share code, notes, and snippets.

@Maras0830
Created March 15, 2017 09:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Maras0830/dc6f627eba005bdfc6b741f7f2ea3178 to your computer and use it in GitHub Desktop.
Save Maras0830/dc6f627eba005bdfc6b741f7f2ea3178 to your computer and use it in GitHub Desktop.
[nginx] same domain map to different project. [Vuex(vue-route) + Laravel]
server {
listen 80;
listen [::]:80;
server_name test.dev;
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;
}
}
@aftabnaveed
Copy link

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