要求:浏览器地址栏输入qj.123.com之后,地址自动变成qj.abc.com

配置nginx跳转

server {
  listen 80;
  server_name qj.abc.com qj.123.com;
  set $domain qj.abc.com;
  index index.php index.html index.htm;
  root /home/web/$domain/htdocs/;

  if ( $host = 'qj.123.com' ){
    rewrite ^/(.*)$ http://qj.abc.com/$1;
  }

  location /{
  index index.php index.htm index.html;
  root $domain;
  }

  location ~ .*\.php${
  include fcgi.conf;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  expires off;
  access_log /home/logs/nginx/qj.abc.log;
  }

}

 

【符号解析】

^ 匹配字符串的开始

/ 匹配域名的分隔符

. 匹配除换行符以外的任意字符

* 重复0次或更多次

(.*) 匹配任意字符

.* 匹配任意文本

$ 匹配字符串的结束

相关文章:

  • 2021-05-25
  • 2021-10-14
  • 2021-09-08
  • 2021-07-10
  • 2022-12-23
  • 2021-09-13
猜你喜欢
  • 2021-08-02
  • 2022-12-23
  • 2021-10-26
  • 2021-12-09
  • 2022-12-23
  • 2021-08-08
  • 2021-11-23
相关资源
相似解决方案