การทำ Redirect from HTTPS เป็น HTTP

มีบางกรณีเฉพาะที่คุณต้องการเปลี่ยนเส้นทาง URL บางรายการหรือเว็บไซต์เดียวให้เปิดผ่าน HTTP แทน HTTPS สำหรับกรณีนี้ คุณควรเพิ่มกฎการเขียนซ้ำ (rewrite rule) ต่อไปนี้ในไฟล์ .htaccess ของคุณ:

# Redirect HTTPS to HTTP
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

วิธีอื่นๆ

หากต้องการ บังคับใช้ HTTP เท่านั้น และป้องกันไม่ให้มีการเข้าถึงผ่าน HTTPS เลย สามารถทำได้โดยการตั้งค่าเว็บเซิร์ฟเวอร์ให้ไม่รับการเชื่อมต่อ HTTPS และ Redirect ทุกคำขอ HTTPS กลับไปที่ HTTP

 

 

---

 

1. Apache (httpd)

 

1.1 ปิด HTTPS และ Redirect ไป HTTP

 

แก้ไขไฟล์ .htaccess หรือไฟล์คอนฟิก httpd.conf

 

RewriteEngine On

RewriteCond %{HTTPS} on

RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

 

รีโหลด Apache

 

systemctl restart httpd

 

 

 

---

 

2. Nginx

 

2.1 ปิด HTTPS และ Redirect ไป HTTP

 

แก้ไขไฟล์คอนฟิก Nginx เช่น /etc/nginx/nginx.conf หรือ /etc/nginx/sites-available/default

 

server {

    listen 443 ssl;

    server_name yourdomain.com;

    return 301 http://$host$request_uri;

}

 

server {

    listen 80;

    server_name yourdomain.com;

    root /var/www/html;

    index index.html index.php;

}

 

รีโหลด Nginx

 

systemctl restart nginx

 

 

 

---

 

3. OpenLiteSpeed

 

3.1 ปิด HTTPS และ Redirect ไป HTTP

 

เข้า WebAdmin Console (https://yourserver:7080)

 

ไปที่ Virtual Hosts → เลือกโดเมน

 

ไปที่ Rewrite Rules และเพิ่ม:

 

RewriteCond %{HTTPS} on

RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

 

ไปที่ Listener และลบ HTTPS Listener

 

รีสตาร์ท OpenLiteSpeed

 

systemctl restart lsws

 

 

 

---

 

4. DirectAdmin

 

4.1 ปิดบังคับ HTTPS

 

ไปที่ Admin Level → Custom HTTPD Configurations

 

เลือกโดเมน แล้วตรวจสอบ Redirect ไปยัง https:// และลบออก

 

 

 

---

 

5. Plesk

 

5.1 ปิด HTTPS และ Redirect ไป HTTP

 

ไปที่ Hosting Settings ของโดเมน

 

ปิด Permanent SEO-safe 301 redirect from HTTP to HTTPS

 

เพิ่ม .htaccess ไฟล์:

 

RewriteEngine On

RewriteCond %{HTTPS} on

RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

 

 

 

---

 

6. ปิด HSTS (Strict Transport Security)

 

หากเคยเปิด HSTS อาจต้องปิดโดย:

 

เพิ่ม Header ปิด HSTS ใน nginx.conf หรือ .htaccess

 

Header always set Strict-Transport-Security "max-age=0; includeSubDomains"

 

รีสตาร์ทเซิร์ฟเวอร์ และล้างค่า HSTS ในเบราว์เซอร์

 

 

 

---

 

7. ทดสอบ

 

ใช้ curl ตรวจสอบ Redirect

 

curl -IL https://yourdomain.com

 

ต้องได้ HTTP/1.1 301 Moved Permanently ไปที่ http://yourdomain.com

 

 

 

---

 

สรุป: วิธีนี้จะบังคับให้ทุกการเชื่อมต่อ HTTPS ถูก Redirect กลับไป HTTP และปิดการเข้าถึง HTTPS ทั้งหมด

 

 

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

จะทำการ block IP โดยใช้ .htaccess ได้อย่างไร

สามารถทำได้โดยระบุ IP ที่ต้องการบลอกที่ .htaccess ไฟล์ โดเยการสร้างไฟล์วางไว้ที่ public_html...

วิธีการเปลี่ยนหน้าแรกจากไฟล์ index เป็นชื่ออื่นที่ต้องการใน hosting ของเรา

ภายในไฟล์ .htacess ให้ระบุข้อมูลต่อไปนี้ครับ DirectoryIndex ชื่อไฟล1 ชื่อไฟล์2 ชื่อไฟล์3...

Leverage browser caching

Change the request headers of your resources to use caching. Optimize your caching strategy....

How to enable displaying php errors on site

To enable displaying PHP errors Open your website with file manager61 Go...

การป้องกัน Hotlink: วิธีการป้องกันไม่ให้ผู้อื่นขโมยไฟล์ของคุณ

สร้างไฟล์. htaccess ในไดเร็กทอรี public_html ของคุณโดยใช้รหัสต่อไปนี้: RewriteEngine on...