nginx 不带www到www域名的重定向
如果是单次重定向用 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;
}
........................
}
- 上一篇 »HTTP中的重定向和请求转发的区别
- 下一篇 »HTML网页自动跳转,重定向