🚀 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 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, Naiba Notes' configuration file 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;
省略其他配置
}
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.

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

「Naibabiji WordPress Website Building Coaching Service」—From choosing a domain and buying hosting, to installing a Theme and publishing content, I「ll coach you through every step, helping you avoid detours and reach your goal directly.

👉 Learn about the 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 QR Code to Follow

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: