nginx HTTP强制跳转HTTPS Rewrite规则

if ($server_port = 80) {
return 301 https://$server_name$request_uri;
}
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
error_page 497 https://$server_name$request_uri;

注意:你应该给每一个站点单独设置Rewrite规则;

 

附上几条自己用的Wordperss伪静态规则

location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

 

nginx Wordperss 访问后台/出错规则

rewrite ^/sitemap.xml$ /xmlmap.php;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

随手笔记,方便你我他。

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注