nginx 不带www到www域名的重定向
时间:2014-08-28 18:27 来源:linux.it.net.cn 作者:it
这里,如果是单次重定向用 redirect, 如果永久跳转用 permanent,这里用 permanent
{
listen 80;
server_name xxx.com www.xxx.com;
index index.html index.php;
root /data/www/wwwroot;
if ($http_host !~ "^www.xxx.com$") {
rewrite ^(.*) http://www.xxx.com$1 permanent;
}
........................
}
(责任编辑:IT)
这里,如果是单次重定向用 redirect, 如果永久跳转用 permanent,这里用 permanent { listen 80; server_name xxx.com www.xxx.com; index index.html index.php; root /data/www/wwwroot; if ($http_host !~ "^www.xxx.com$") { rewrite ^(.*) http://www.xxx.com$1 permanent; }
........................ } |