将https www重定向到http非www nginx

时间:2016-02-06 18:55:16

标签: nginx configuration

我正在尝试将https重定向到http,将www重定向到非www。 但遗憾的是它没有用。

我需要它做的例子:

  1. https://www.example.com - > http://example.com/
  2. http://www.example.com - > http://example.com/
  3. 到目前为止,我所做的是:

    # Redirect https to http:
    #
    server {
        listen 443;
        server_name www.example.com expample.com;
        return 301 http://example.com$request_uri;
    }
    # Redirect www to non-www.
    #
    server {
        #listen 80 is default
        server_name www.example.com;
        return 301 $scheme://example.com$request_uri;
    }
    
    # The actual server configuration goes here:
    #
    server {
        listen       80;
        server_name  example.com;
    
    #rest of the block configuration
    

    向前谢谢!

0 个答案:

没有答案