Author Topic: apache .htaccess redirect http to https  (Read 3822 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
apache .htaccess redirect http to https
« on: กุมภาพันธ์ 23, 2016, 12:30:36 AM »
ต้องการให้ redirect subdomain
เมื่อเข้าจาก http://money.packetlove.com  เป็น https://money.packetlove.com ทุกครั้ง
#cd money
#vi .htaccess

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^money\.
RewriteRule .* https://money.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]