admin
admin
3798 0 0

Nginx 域名转向从www 到裸域名

目的:把域名www.domain.com 转到domain.com 下面的两个代码可以实现

if ($host ~* www\.(.*))
{
    set $host_without_www $1;
    rewrite ^(.*)$ http://$host_without_www$1 permanent;
}

# Redirect www to non-www
server
{
    server_name ~^www\.(?P<domain>.+)$;
    rewrite ^ http://$domain$request_uri permanent;
}

摘菜 http://blog.sramana.in/www-to-non-www-in-nginx

0

See Also

Nearby


Discussion

Login Topics