码迷,mamicode.com
首页 > 其他好文 > 详细

nginx根目录跳转

时间:2018-07-06 11:22:40      阅读:355      评论:0      收藏:0      [点我收藏+]

标签:http   nbsp   man   域名   $1   make   跳转   需求   根目录   

访问域名  
www.adc.com/image  自动跳转到  www.adc.com/make/image  
这个如何写

这种需求有多种方法可以实现:
1. 利用Nginx rewrite 内部跳转实现:       
location /image {
          rewrite ^/image/(.*)$     /make/image/$1 last;
}


2.利用alias映射
location  /image  {
       alias  /make/image;  #这里写绝对路径
}


3.利用root映射:
location  /image {
      root   /make;
}


4.利用nginx的permanent 301绝对跳转实现
location /image {
        rewrite ^/image/(.*)$   http://www.adc.com/make/image/$1;
}
   


5.判断uri实现
if ( $request_uri ~* ^(/image)){
        rewrite ^/image/(.*)$ /make/image/$1 last; 
}

nginx根目录跳转

标签:http   nbsp   man   域名   $1   make   跳转   需求   根目录   

原文地址:https://www.cnblogs.com/jcici/p/9272167.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!