Linux10.5 Nginx域名重定向
Posted Learning Notes
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux10.5 Nginx域名重定向相关的知识,希望对你有一定的参考价值。
更改test.com.conf server { listen 80; server_name test.com test1.com test2.com; index index.html index.htm index.php; root /data/wwwroot/test.com; if ($host != ‘test.com‘ ) { rewrite http://$host/(.*)$ http://test.com/$1 permanent; } } // $1就是(.*)括号内的 [[email protected] ~]# curl -x127.0.0.1:80 test2.com/index.html <html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx/1.12.1</center> </body> </html> [[email protected] ~]# curl -x127.0.0.1:80 qq.com/index.html echo “This is a default site.” [[email protected] ~]# curl -x127.0.0.1:80 test1.com/index.html <html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx/1.12.1</center> </body> </html>
以上是关于Linux10.5 Nginx域名重定向的主要内容,如果未能解决你的问题,请参考以下文章