nginx地址重定向
来源:互联网 发布:风险评估xy矩阵法 编辑:程序博客网 时间:2024/05/16 15:14
1、假设要把webroot/static/index.html访问重定向到static/index.html
例如当我们通过浏览器访问http://192.168.11.210/webroot/static/index.html,实际访问的是web目录下面的static/index.html文件,也及去掉了webroot这个目录,使用alias
location ^~ /webroot/ { alias /data/www/web/WebContent/;}注意:
1. 使用alias时,目录名后面一定要加"/"。
2. alias可以指定任何名称。
3. alias在使用正则匹配时,必须捕捉要匹配的内容并在指定的内容处使用。
4. alias只能位于location块中。[/warning]
http://192.168.11.210/webroot/test/static/index.html
location ^~ /webroot/test/ { alias /data/www/web/WebContent/;}这样也是可以的,最终访问的文件跟上面是一样的。
2、把对webroot/static/index.html的访问重定向到web目录下面的test目录下
location ~ ^/webroot/ { root /data/www/web/WebContent/test/;}http://192.168.11.210/webroot/static/index.html 实际访问的是web目录下testwebroot/static/index.html
及使用root一般是把访问目录重定向到某个目录下,但是访问的路径必须在重新定位的目录下
注意区分跟alias的区别
转载一个:
访问域名
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地址重定向
- Nginx地址重定向使用
- nginx重定向规则
- nginx 301重定向
- nginx虚拟主机重定向
- nginx 301重定向
- nginx 重定向例子
- nginx 域名重定向
- nginx实现重定向
- 获取重定向地址
- IP地址重定向
- nodejs地址重定向
- nginx rewrite arg 带问号的地址转发参数处理?Nginx重定向的参数问题
- [nginx] 怎么配置nginx rewrite,才不会引起浏览器url地址重定向?
- nginx 此页面重定向不正确(检测到该服务器正在将此地址的请求循环重定向)
- Nginx 301重定向域名
- nginx实现301重定向
- NGINX 的301 重定向
- 数据库索引
- Spring学习-AOP
- 简介mybatis一对多的collection
- 找不到 Class BASE64Decoder 的解决办法
- Volley
- nginx地址重定向
- QT在VS2013上的配置
- 一个例子搞懂编码问题
- ES6 destructuring 解构赋值
- ubuntu编译websocketpp的example程序, 终于可以不用装boost了
- 简单光照模型(Lambert 光照模型)
- 数字的正则表达式,python
- WebSocket原理说明
- Tmux 多窗口操作