If a website uses both HTTPS and HTTP protocols, for SEO and consistency purposes, HTTP access is 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, the configuration file for Naiba Notes is located at /usr/local/nginx/conf/vhost/blog.naibabiji.com.conf. After opening, the general format is as follows.
server {
listen 80;
server_name blog.naibabiji.com;
省略其他配置
}
server {
listen 443 ssl;
server_name blog.naibabiji.com;
省略其他配置
}The part you need to modify is the content of the `listen 80;` line of code (80 is for HTTP, 443 is for 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 the file and restart Nginx to redirect HTTP access to HTTPS.
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.