zoukankan      html  css  js  c++  java
  • vue nginx 同一端口下两个同级目录处理方法

    vue nginx 同一端口下两个同级目录处理方法,
    例:链接http://xxx.com 访问目录一;http://xxx.com/store 访问目录二;
    
    方法解析:
      1、先定义变量并将后面 上级目录(相对主目录的上级)/ 根目录 主目录赋值给$root 变量;
      2、用正则表单试判断url访问的是否为目录二,如果是则 上级目录(相对主目录的上级) 赋值给$root变量
    
      3、 location /store 做vue 跳转处理,注意必须加上 /目录二/index.html
    
    
        #端口号
        listen 80;
            #域名
        server_name xxx.com;
    
            #定义变量  此为目录一 
        set $root data/web;    
        #判断url中是否存在 /store 目录
        if ( $request_uri ~* ^/store ) {
                    #定义变量 此为目录二 绝对路径:/mnt/data/store
            set $root data;
        }
    
            #组合拼接引用目录
        root /mnt/$root;
    
        index index.php index.html index.htm;
    
        location ~ .(htm|html)$ {
            add_header Cache-Control no-store;
            expires -1;
        }
        
        location / {
                #根目录跳转
                try_files $uri $uri/ /index.html =404;
        }
        
            # 此为目录二 必须对应上面的目录二
        location /store { 
                 #目录跳转  注意 这里必须为 /目录二/index.html; 
                 try_files $uri $uri/ /store/index.html; 
        } 
    
        error_page 404 /index.html; 
        location ~* ^.+.(jpg|jpeg|gif|png|bmp)$ { 
            access_log off; 
            expires 30d; break; 
        } 
        
  • 相关阅读:
    jekins构建自动化项目的步骤
    CRT 和mysql 中文乱码解决方式
    Jenkins的配置(rpm red hat方式)
    MapReduce job.setNumReduceTasks(0)思考
    浏览器angent分析工具
    npm中的 --save-dev
    computed与methods的异同
    JS函数种类详解
    Vue.js和Nodejs的关系
    AJAX复习笔记
  • 原文地址:https://www.cnblogs.com/zwb121/p/11511616.html
Copyright © 2011-2022 走看看