Nginx学习笔记15rewrite之redirect临时重定向
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx学习笔记15rewrite之redirect临时重定向相关的知识,希望对你有一定的参考价值。
redirect标志跟permanent标志的区别是:redirect使用HTTP 302临时重定向,permanent使用HTTP 301永久重定向。本文介绍redirect标志的临时重定向动作。
nginx配置:
location ~ ^/app2/ {
rewrite ^/app2/(.*)$ /app/$1 redirect;
}
运行结果:
curl -v http://ng.coe2coe.me:8000/app2/
* Hostname was NOT found in DNS cache
* Trying 192.168.197.101...
* Connected to ng.coe2coe.me (192.168.197.101) port 8000 (#0)
> GET /app2/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: ng.coe2coe.me:8000
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
* Server nginx/1.11.8 is not blacklisted
< Server: nginx/1.11.8
< Date: Sun, 09 Jul 2017 10:27:48 GMT
< Content-Type: text/html
< Content-Length: 161
< Location: http://ng.coe2coe.me:8000/app/
< Connection: keep-alive
<
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.11.8</center>
</body>
</html>
* Connection #0 to host ng.coe2coe.me left intact
以上是关于Nginx学习笔记15rewrite之redirect临时重定向的主要内容,如果未能解决你的问题,请参考以下文章
Nginx学习笔记14rewrite之permanent永久重定向