Nginx domain name rewrite does not add www to add www.

Source: Internet
Author: User
server {Listen 80;server_name www.xxxx.net xxxx.net; #配置发布目录为/usr/local/nginx/data/rw-owsroot/usr/local/nginx/data/ Rw-ows, #添加以下405代码error_page 405 =200 $uri; Location/{proxy_next_upstream http_502 http_504 error timeout invalid_header;proxy_set_header Host $host;p roxy_set_               Header X-real-ip $remote _addr;proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;proxy_pass http://rw-ows; #=========================cors nginx Configuration ============================= if ($http _origin ~* (https?:/ /[^/]*\.roamwifi\.net (: [0-9]+)?)                $) {Set $cors "true";                   } if ($request _method = ' OPTIONS ') {set $cors "${cors}options";      } if ($request _method = ' GET ') {set $cors "${cors}get";    } if ($request _method = ' POST ') {set $cors "${cors}post";       } if ($cors = "Trueget") {add_header ' Access-control-allow-origin ' "$http _origin"; Add_header ' access-Control-allow-credentials ' true ';        } if ($cors = "Truepost") {add_header ' Access-control-allow-origin ' "$http _origin";        Add_header ' access-control-allow-credentials ' true ';                  } if ($cors = "Trueoptions") {#add_header ' Access-control-allow-origin ' "$http _origin";          Add_header ' Access-control-allow-origin ' *;        Add_header ' access-control-allow-credentials ' true ';        Add_header ' Access-control-max-age ' 1728000; Add_header ' Access-control-allow-headers ' Authorization,content-type,accept,origin,user-agent,dnt,cache-control                 , X-mx-reqtoken,keep-alive,x-requested-with,if-modified-since ';                 Add_header ' content-length ' 0;                 Add_header ' Content-type ' Text/plain charset=utf-8 ';                  #return 200;      return 204; }} #动态页面交给http://rw-ows,location ~. *\. (JSP|DO)? $ {proxy_set_header Host $host;p roxy_set_header x-real-ip $remote _addr;proxy_set_header x-forwarded-for $ Proxy_aDd_x_forwarded_for;proxy_pass Http://rw-ows;} #配置Nginx动静分离, defined static pages are read directly from the Nginx publishing directory. Location ~. *\. (html|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf) $ {root/usr/local/nginx/data/xxxx; #expires定义用户浏览器缓存的时间为1天,        If the static page is not updated frequently, it can be set longer, which can save bandwidth and relieve the pressure of the server expires 1d;}        Location =/anon_login.jsp {return 301 https://$server _name$request_uri;        } location =/anon_register.jsp {return 301 https://$server _name$request_uri;        } location =/anon_forgetpwd.jsp {return 301 https://$server _name$request_uri;          } if ($host! = ' www.xxxx.net ') {rewrite "^/(. *) $" http://www.xxxx.net/$1 permanent; } }

The above describes the Nginx domain name rewrite does not add www to add www., including the contents of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.