【问题标题】:nginx one domain and multiple projects setting aliasnginx一域多项目设置别名
【发布时间】:2017-08-05 18:15:23
【问题描述】:

我想使用一个域来映射不同的项目。

mydomain.com.tw => /var/www/project1/public
mydomain.com.tw/test => /var/www/project2

mydomain.com.tw/project2/detail 始终指向 mydomain.com.tw 项目路径。

project1 => laravel
project2 => vue 和使用 vue-route

listen 80;
listen [::]:80;

server_name mydomain.dev;

index index.php index.html index.htm;
root /var/www/project1/public;

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

location /lottery {
    alias /var/www/project2/dist;
    try_files $uri $uri/ @rewrites;
}

location @rewrites {
    rewrite ^(.+)$ /index.html last;
}

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;
}

【问题讨论】:

  • 您可以使用子域代替吗? (mydomain.dev 和 project2.mydomain.dev)。
  • @Lucas 否,因为需要使用相同的本地存储项。
  • 您是否尝试过使用其他浏览器清除浏览器 DNS 缓存?有时这会发生在我身上。
  • @Lucas 谢谢你的建议,我通过this解决了

标签: laravel nginx routes vue.js


【解决方案1】:

我解决了这个问题。

解决方案:

https://gist.github.com/Maras0830/dc6f627eba005bdfc6b741f7f2ea3178

【讨论】:

    猜你喜欢
    • 2020-01-06
    • 1970-01-01
    • 2019-03-30
    • 2016-12-08
    • 2017-03-31
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    相关资源
    最近更新 更多