Nginx multiple domain names point to the same website
PHP中文网
PHP中文网 2017-05-16 17:29:53
0
3
592

My domain name is example.com
I want www.example.com to jump to example.com
My nginx configuration is

server {
       listen 80;
       server_name www.example.com example.com;
       root /var/www/web;

       if ($http_host == "www.example.com") {
                 rewrite ^ http://example.com$request_uri permanent;
       }

no. . .

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
大家讲道理
server {
  listen 80;
  server_name www.example.com;
  return 301 http://example.com/$request_uri;
}

server {
  listen 80;
  server_name example.com;
  root /var/www/web;
}
某草草
if ($host = 'www.example.com' ) {
    rewrite ^/(.*)$ http://example.com/$1 permanent;
}
Peter_Zhu
if ($http_host = www.example.com) {
    rewrite  (.*)  http://example.com$1 permanent;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template