首页 > 其他分享 >2. 使用rewrite规则实现将所有到a域名的访问rewrite到b域名

2. 使用rewrite规则实现将所有到a域名的访问rewrite到b域名

时间:2022-08-15 14:37:38浏览次数:42  
标签:www rewrite magedu 访问 域名 html org

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

标签:www,rewrite,magedu,访问,域名,html,org
From: https://www.cnblogs.com/biaoming534/p/16588178.html

相关文章

  • android 文件访问权限处理
    对于/storage/emulated/0没没有权限访问的问题进行如下解决:1、加入文件读写、和存储管理权限READ_EXTERNAL_STORAGE MANAGE_EXTERNAL_STORAGE requestLegacyExternal......
  • nginx 一些简单访问控制模块
    nginx已经内置了一些简单的访问控制模块,利用好这些模块我们可以提升系统的安全几个比较有用的标准模块基本都是利用了access阶段的能力limit_except限制请求方法的(......
  • Linux 域名和DNS
    名字解析的作用:TCP/IP网络中,设备之间的通信依赖IP地址来实现,但是IP地址不好记忆,所以就将每一台设备用一个名字来进行标识,但是这个名字计算机不能解析。所以就需要借助名字......
  • Django设置跨域访问
    Django设置跨域访问(1)安装DjangoCorsHeaderspipinstalldjango-cors-headers(2)settings.py配置如下INSTALLED_APPS=[#'django.contrib.admin','d......
  • 【问题解决】解决使用aliyuncdn加速的域名证书不同步问题
    今天登录上博客发现好家伙资源链全挂了,进去一看发现是证书到期了,但是我回服务器查看证书发现证书已经更新而且是有效状态,清缓存一类的都尝试过了,依旧不行,然后网上找到了一......
  • https网页访问http资源失败无法显示
    问题:部署云服务后使用https://域名访问,页面无法显示外链的http图片。排查:img标签的src会经过浏览器,请求地址被转换成https://外链地址。起初......
  • 《Effective Java》第16条:要在仅有类中使用访问方法而非公有域
    《EffectiveJava》第16条:要在仅有类中使用访问方法而非公有域一、问题有时候我们需要定义一些类用来集中实例域(Java对象中的数据)。经常我们会把这些数据域声明为public......