NGINX 地址重写
需求一 : 访问 a.html 重定向到 b.html ( 地址栏自动重写 )
修改配置文件
[root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf
.. ..
server {
listen 80;
server_name localhost;
# 访问 a.html重定向到 b.html (地址栏自动重写)
rewrite /a.html /b.html;
location / {
root html;
index index.html index.htm;
}
}
[root@proxy ~]# echo "BB" > /usr/local/nginx/html/b.html
重新加载配置文件
[root@proxy ~]# /usr/local/nginx/sbin/nginx -s reload
客户端测试
[root@client ~