
If a website enables both HTTPS and HTTP protocols, for SEO and consistency considerations, HTTP access will be redirected to HTTPS. If you are using the LNMP one-click package or nginx, you can achieve a 301 redirect to HTTPS using the method below.

Open your website's configuration file, for example, Naibabiji's configuration file is at /usr/local/nginx/conf/vhost/blog.naibabiji.com.conf
After opening, the format is roughly as follows
server {
listen 80;
server_name blog.naibabiji.com;
省略其他配置
}
server {
listen 443 ssl;
server_name blog.naibabiji.com;
省略其他配置
}What you need to modify is the content of the line `listen 80;` (80 is HTTP, 443 is HTTPS).
server {
listen 80;
server_name blog.naibabiji.com;
return 301 https://blog.naibabiji.com$request_uri;
}
server {
listen 443 ssl;
server_name blog.naibabiji.com;
省略其他配置
}Then save and restart nginx to achieve HTTP access redirecting to HTTPS.