nginx中配置域名跳转示例
如访问http://a.qing.com/abc 时跳转到http://aaaaa.qing.com/www/ccccc?p=abc
server {
listen 80;
server_name a.qing.com ;
access_log /usr/local/nginx/logs/uyeepay.log access;
rewrite ^/([0-9a-z]+)$ http://aaaaa.qing.com/www/ccccc?p=$1 last;
}
如访问http://www.minjietong.com时跳转到http://www.minjietong.com/mjt/index.do
server {
listen 80;
server_name www.minjietong.com;
rewrite ^/?$ /mjt/index.do redirect;
location ~ ^/mjt/
{
index index.action index.jsp client.html;
proxy_set_header x-forwarded-for $remote_addr;
proxy_pass http://112.13.253.17:8080;
}
}
server {
listen 80;
server_name m.minjietong.com;
rewrite ^/?$ /mjt/wap/index.do last;
location ~ ^/mjt/
{
index index.action index.jsp client.html;
proxy_set_header x-forwarded-for $remote_addr;
proxy_pass http://112.13.253.17:8080;
}
}
本文提供Nginx中配置域名跳转的示例,包括将访问http://a.qing.com/abc自动跳转到http://aaaaa.qing.com/www/ccccc?p=abc,以及如何跳转http://www.minjietong.com到http://www.minjietong.com/mjt/index.do。同时展示如何实现路径映射。
824

被折叠的 条评论
为什么被折叠?



