Redirect website wordpress http sang https trên cloudflare, web server nginx

Redirect website wordpress http sang https trên cloudflare, web server nginx

1./ Cách 1 Redirect trên Cloudflare

2./ Cách 2 Redirect trên nginx.

Chỉnh sửa và thay đổi domain của bạn theo như bên dưới.

server {

 ​​ ​​​​ listen  ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ 80;

 ​​ ​​​​ server_name  ​​ ​​​​ example.com www.example.com;

 

 ​​ ​​​​ if ($http_x_forwarded_proto = "http") {

 ​​ ​​ ​​ ​​​​ return 301 https://$server_name$request_uri;

 ​​ ​​​​ }

Trường hợp áp dụng thực tế

 ​​ ​​ ​​ ​​​​ server_name  ​​ ​​​​ cloudx.com.vn www.cloudx.com.vn;

 ​​ ​​ ​​ ​​ ​​​​ if ($http_x_forwarded_proto = "http") {

 ​​ ​​ ​​ ​​ ​​​​ return 301 https://cloudx.com.vn$request_uri;

 ​​ ​​ ​​ ​​ ​​​​ }

Có thể áp dụng cả cách 1 và cách 2. Nhưng làm cách 1 sẽ tối ưu hơn.

3./ Tham khảo

https://serverfault.com/questions/653976/redirect-loop-using-cloudflares-flexible-ssl/654018

 

 

 

 

 

 

 

BÀI VIẾT CÙNG CHUYÊN MỤC

Không copy được giữa máy Windows và máy ảo qua mRemoteNG/RDP: Nguyên nhân và cách sửa
Không copy được giữa máy Windows và máy ảo qua ...

mRemoteNG Remote Desktop RDP Clipboard Redirection rdpclip.exe VPS Windows ...

Hướng dẫn bật Nested Virtualization trên ESXi để chạy Android Studio Emulator trong máy ảo Windows
Hướng dẫn bật Nested Virtualization trên ESXi để chạy ...

Nested Virtualization ESXi VMware Android Studio Android Emulator WHPX Hyper-V ...

PITR (Point In Time Recovery) là gì? Khôi phục Database về đúng thời điểm cần thiết
PITR (Point In Time Recovery) là gì? Khôi phục ...

PITR, Point In Time Recovery, PITR là gì, Database Recovery, PostgreSQL PITR, ...

Backup Database Full, Incremental, Differential khác nhau thế nào?
Backup Database Full, Incremental, Differential khác ...

Backup Database, Full Backup, Incremental Backup, Differential Backup, Backup ...

Database Cluster là gì? High Availability, Failover và Cluster Database hoạt động như thế nào?
Database Cluster là gì? High Availability, Failover và ...

Database Cluster, Database Cluster là gì, High Availability Database, Database ...