server {
listen 80;
server_name dev.wangsl.com;
index index.html index.php index.htm;
access_log
/usr/local/nginx/logs/8080-access
.log main;
error_log
/usr/local/nginx/logs/8080-error
.log;
rewrite ^(.*)$ https:
//
$host$1 permanent;
//
这是ngixn早前的写法,现在还可以使用。
location ~ / {
root
/var/www/html/8080
;
index index.html index.php index.htm;
}
}
================================================================
上面的跳转配置rewrite ^(.*)$ https:
//
$host$1 permanent;
也可以改为下面
rewrite ^/(.*)$ http:
//dev
.wangsl.com/$1 permanent;
或者
rewrite ^ http:
//dev
.wangsl.com$request_uri? permanent;
================================================================
server {
listen 80;
server_name dev.wangsl.com;
index index.html index.php index.htm;
access_log
/usr/local/nginx/logs/8080-access
.log main;
error_log
/usr/local/nginx/logs/8080-error
.log;
return
301 https:
//
$server_name$request_uri;
//
这是nginx最新支持的写法
location ~ / {
root
/var/www/html/8080
;
index index.html index.php index.htm;
}
}
server {
listen 80;
server_name dev.wangsl.com wangsl.com *.wangsl.com;
index index.html index.php index.htm;
access_log
/usr/local/nginx/logs/8080-access
.log main;
error_log
/usr/local/nginx/logs/8080-error
.log;
if
($host ~*
"^wangsl.com$"
) {
rewrite ^/(.*)$ https:
//dev
.wangsl.com/ permanent;
}
location ~ / {
root
/var/www/html/8080
;
index index.html index.php index.htm;
}
}
server {
listen 80;
server_name dev.wangsl.com;
index index.html index.php index.htm;
access_log
/usr/local/nginx/logs/8080-access
.log main;
error_log
/usr/local/nginx/logs/8080-error
.log;
if
($host =
"dev.wangsl.com"
) {
rewrite ^/(.*)$ http:
//dev
.wangsl.com permanent;
}
location ~ / {
root
/var/www/html/8080
;
index index.html index.php index.htm;
}
}