nginx 配置301转发

时间:2022-03-04 20:24:29

1. 设置域名解析

daijun.me 指向 234.33.22.21

2.主机234.33.22.21 nginx配置 转发

 server {
    listen 80;
    server_name daijun.me www.daijun.me;
    access_log /data/wwwlogs/access_nginx.log combined;
   # root /data/wwwroot/default;
   # index index.html index.htm index.php;
    if ($host = 'daijun.me' ) {
      rewrite ^/(.*)$ http://www.cnblogs.com/wangdaijun/$1 permanent;
    }
    if ($host = 'www.daijun.me' ) {
      rewrite ^/(.*)$ http://www.cnblogs.com/wangdaijun/$1 permanent;
     }
}
location 语法规则

http://www.cnblogs.com/lidabo/p/4169396.html

http://wiki.nginx.org/NginxHttpCoreModule#location