在nginx.conf里面 include /etc/nginx/conf.d/*.conf;
在应该server里增加:
if ($http_host !~ “^xxx.com”) {
rewrite /.* http://xxx.com$uri permanent;
}
注意:!~ “^xxx.com” 这个xxx是你的域名,不用在前面带www.的
server_name xxx.com www.xxx.com;
access_log /var/log/nginx/access_shichuannet.com.log;
error_log /var/log/nginx/error_shichuannet.com.log;
日志代码放在server_name下,上面的if语句放在日志下面
其他二级域名使用另外的server,不受这个跳转的影响
——————————
apache的.htaccess代码
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.\.me$ [NC]
RewriteRule ^(.*)$ http://googlo.me/$1 [L,R=301]
————————
server {
listen 80;
server_name DOMAIN.com www.DOMAIN.com;
access_log /var/log/nginx/DOMAIN.com.log;
error_log /var/log/nginx/DOMAIN.com.log;
if ($http_host !~ “^DOMAIN.com”) {
rewrite /.* http://DOMAIN.com$uri permanent;
}
location / {
client_max_body_size 10m;
index index.html index.htm index.jsp;
proxy_set_header Host $host;
proxy_pass_header User-Agent;
proxy_pass http://localhost:8089/;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
评论
评论已关闭!