jQuery火箭图标返回顶部代码 - 站长素材

nginx 配置路由规则转发配置记录

工作中公司要求针对经销商PC端和工厂PC端的访问地址固定访问。

经销商PC端 http://localhost/

工厂PC端   http://localhost/fac

 

文件磁盘路径:

/crm/nginx-pages

  |---- admin

  |---- adminfac

 

 经销商端:

 

location ^~ /admin {
               root /crm/nginx-pages/;
               index index.html;
               rewrite ^/admin/(.*)\.*$ /admin/$1 break;
        }

 

 

 

  工厂端:

location ^~ /adminfac {
               root /crm/nginx-pages/;
               index index.html;
               rewrite ^/adminfac/(.*)\.*$ /adminfac/$1 break;
        }

 

 

路由定向:

location / {
               if ($uri = /) {
                  rewrite / http://$host/admin? permanent;
               }
               if ($uri = /fac) {
                  rewrite /fac http://$host/adminfac? permanent;
               }
               #try_files $uri $uri/ =404;
        }

 针对url地址和nginx映射磁盘地址不一致处理。

 

nginx 定向参数:
last - 完成重写指令,之后搜索相应的URI或location。 break - 完成重写指令。 redirect - 返回302临时重定向,如果替换字段用http://开头则被使用。 permanent - 返回301永久重定向。

 

其它命令:

nginx -t -c /etc/nginx/nginx.conf #nginx校验配置文件是否可用
nginx -s reload #nginx重新加载
nginx -s stop #nginx停止
nginx -c /etc/nginx/bginx.conf #nginx启动

 

posted @ 2019-04-30 15:55  bingco  阅读(21403)  评论(0编辑  收藏  举报