2. 使用rewrite规则实现将所有到a域名的访问rewrite到b域名
2. 使用rewrite规则实现将所有到a域名的访问rewrite到b域名
a域名:www.magedu.org
b域名:m.magedu.org
a域名配置: #将a域名的所有的连接都临时跳转到b域名
server {
listen 80;
server_name www.magedu.org;
root /data/nginx/html/pc;
default_type text/html;
location / {
root /data/nginx/html/pc;
rewrite / http://m.magedu.org redirect;
}
}
b域名配置:
server {
listen 80;
server_name m.magedu.org;
root /data/nginx/html/mobile;
location / {
root /data/nginx/html/mobile;
}
}
#测试访问
[root@CentOS8 mobile]# curl www.magedu.org -Lv
* Rebuilt URL to: www.magedu.org/
* Trying 10.0.0.8...
* TCP_NODELAY set
* Connected to www.magedu.org (10.0.0.8) port 80 (#0)
> GET / HTTP/1.1
> Host: www.magedu.org
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
< Server: nginx/1.18.0
< Date: Sat, 13 Aug 2022 17:05:01 GMT
< Content-Type: text/html
< Content-Length: 145
< Connection: keep-alive
< Location: http://m.magedu.org
<
* Ignoring the response-body
* Connection #0 to host www.magedu.org left intact
* Issue another request to this URL: 'http://m.magedu.org'
* Rebuilt URL to: http://m.magedu.org/
* Trying 10.0.0.8...
* TCP_NODELAY set
* Connected to m
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器