Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

问个nginx 配置里面的 域名跳转301 问题

问个nginx 配置里面的 域名跳转301 问题

想把www.qqq.com 全部永久301重定向到 www.aaa.com
下面是我的nginx里面的配置。我下面的代码不成功。不知道正确的怎么实现呢?

server {
        listen 443 ssl;
        server_name www.qqq.com qqq.com;
        ssl_certificate 1_www.qqq.com_bundle.crt;
        ssl_certificate_key 2_www.qqq.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        charset UTF-8;

        client_max_body_size 75M;
        fastcgi_buffers   8 128k;
        fastcgi_busy_buffers_size 128k;


        location / {
                include uwsgi_params;
                uwsgi_pass 127.0.0.1:12008;
                uwsgi_send_timeout 300;
                uwsgi_connect_timeout 300;
                uwsgi_read_timeout 300;
        }
        location /static {
                expires 30d;
                autoindex on;
                #return 403;
                add_header Cache-Control private;
                alias /www/www/html/qqq/static/;
        }
        location /media {
                expires 30d;
                autoindex on;
                #return 403;
                add_header Cache-Control private;
                alias /www/www/html/qqq/media/;
        }
   }

erver{
        listen 80;
        server_name www.qqq.com qqq.com;
        rewrite ^(.*) https://www.aaa.com$1 permanent;
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

为什么我没有看到你https的去做 rewrite?

而且应该是 server你少了个字母。

    server {
        listen 80;
        server_name lilnong.top;
        rewrite ^/(.*)$ https://www.lilnong.top/$1 permanent; 
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...