🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

LNMP One-Click Package nginx 301 Force Redirect to HTTPS Tutorial

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.

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about Website Building Coaching Service
🔒

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.

×
二维码

Scan to Follow