首先,你得先把https配置好 Nginx下配置网站SSL实现https访问(虚拟主机) 然后在nginx文件夹下找到对应的虚拟主机配置文件,路径为:www/wdlinux/nginx/conf/vhost 然后对该虚拟主机配置文件做如下修改:
server { listen 443; root /www/web/guwanlife/public_html;
server_name www.tao.wip52.cn www.[url=https://www.tao.wip52.cn]www.tao.wip52.cn[/url];
index index.html index.php index.htm;
error_page 400 /errpage/400.html;
error_page 403 /errpage/403.html;
error_page 404 /errpage/404.html;
error_page 503 /errpage/503.html;
ssl on;
ssl_certificate_key /www/wdlinux/nginx/conf/aitiancheng.key;
ssl_certificate /www/wdlinux/nginx/conf/aitiancheng.crt; location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ /\.ht {
deny all;
}
include /www/wdlinux/wdcp/rewrite/dzx32_nginx.conf;
}
server {
listen 80;
server_name www.tao.wip52.cn;
return 301 https://$server_name$request_uri;
}
蓝色部分为rewrite规则,原理是监听443端口使用https,监听80端口使用301重定向到https.
关于apache下如何设置301跳转,请看这个教程:https://www.tao.wip52.cn/forum-48-1.html
|