vue部署,nginx同域名多项目部署

1、修改vue生成参数

1、dist/index.html文件修改
    添加 <meta base="/子目录名/">

2、config/index.js文件修改
    修改 assetsPublicPath: '/子目录名/'

3、src/router/index.js文件修改
    添加 base: '/子目录名/'

2、nginx配置

server {
        listen       80;
        root /www/web/www_xxx_com/public_html/public;
        server_name www.xxx.com;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  503 /errpage/503.html;
        location ~ \.php$ {
                proxy_pass http://127.0.0.1:88;
                include naproxy.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
                try_files $uri @apache;
        }
        location @apache {
                 internal;
                 proxy_pass http://127.0.0.1:88;
                 include naproxy.conf;
        }

        

#vue环境部署 方案1
        set $vue_files /www/vue/www_xxx_com;
        location /vue-mobile {
            root $vue_files;
            try_files $uri $uri/ /vue-mobile/index.html;
            if ($http_user_agent !~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
                rewrite  ^/(.*)$  http://$server_name/vue-pc;
            }
        }
        location /vue-pc {
            root $vue_files;
            try_files $uri $uri/ /vue-pc/index.html;
            if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
                rewrite  ^/(.*)$  http://$server_name/vue-mobile;
            }
        }

        # vue环境部署 方案2
        # 设置访问端口重定向
        set $redirect_rewrite pc;
        if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os )?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
            # 设置移动端重定向
            set $redirect_rewrite mobile;
        }
        location /vue-pc {
            # 映射地址
            try_files $uri $uri/ @router;
            if ($redirect_rewrite = mobile) {
                rewrite  ^/(.*)$  $scheme://$server_name/vue-mobile;
            }
        }
        location /vue-mobile {
            # 映射地址
            try_files $uri $uri/ @router;
            if ($redirect_rewrite = pc) {
                rewrite  ^/(.*)$  $scheme://$server_name/vue-pc;
            }
        }
        # 解决访问二级目录刷新404
        location @router {
            rewrite ^.*$ /index.html last;
        }

}

^_^
if('评论、转发、点赞'){
    while (true) echo '无双奥义 BUG消失术';
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值