Nginx no-www to www and www to no-www

前端 未结 17 2185
予麋鹿
予麋鹿 2020-11-22 09:53

I am using nginx on Rackspace cloud following a tutorial and having searched the net and so far can\'t get this sorted.

I want www.mysite.com to go to mysite.com as

17条回答
  •  粉色の甜心
    2020-11-22 10:08

    Ghost blog

    in order to make nginx recommended method with return 301 $scheme://example.com$request_uri; work with Ghost you will need to add in your main server block:

    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    Host                $http_host;
    proxy_set_header    X-Forwarded-Proto   $scheme;
    proxy_set_header    X-NginX-Proxy       true;
    
    proxy_pass_header   X-CSRF-TOKEN;
    proxy_buffering     off;
    proxy_redirect      off;  
    

提交回复
热议问题