force ssl ด้วย php
< ?php if ( !$_SERVER['HTTPS'] ) { header(“location:https://www.yourdomain.com”); exit; } ?>
อีกวิธีการหนึ่งคือใช้ .htaccess
วิธีที่ 1:
SSLOptions +StrictRequire SSLRequireSSL SSLRequire %{HTTP_HOST} eq “domain.com” ErrorDocument 403 https://domain.com
วิธีที่ 2:
SSLOptions +StrictRequire SSLRequireSSL SSLRequire %{HTTP_HOST} eq “domain.com” ErrorDocument 403 https://domain.com
ข้อมูลเพิ่มเติม
http://www.askapache.com/htaccess/apache-ssl-in-htaccess-examples.html http://blog.jozjan.net/2008/02/htaccess-redirect-to-ssl-https-before.html
คัดลอกจาก http://planetmy.com/blog/?p=67
Finally I’m manage to make my PHP 5.1.2 compiled with suPHP successful today suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change [...]
วันนี้ได้มีโอกาสย้ายข้อมูลของเว็บเซิร์ฟเวอร์ ในเครื่องใหม่มีการติดตั้ง SELINUX ไว้ด้วย ทีนี้ผมต้องการย้าย home ของเว็บเพจจาก /var/www ให้เป็น /home/httpd เพื่อให้เหมือนกับโครงสร้างเดิม ผมก็เลยดำเนินการแก้ไขไฟล์ httpd.conf จาก /var/www ให้เป็น /home/httpd ทั้งหมด แล้วก็ restart apache ใหม่ ผลปรากฏว่า start apache ไม่ได้ และมีข้อความเตือนดังนี้
Starting httpd: Syntax error on line 265 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory
[FAILED]
ผมมั่นใจว่าแก้ไขไฟล์ httpd.conf ถูกแน่ๆ เลยลองเข้าไปดูใน /var/log/message ก็พบข้อความ error ต่อไปนี้
Sep [...]
เมื่อวานผมจะ upgrade PHP เป็น 4.3.10 แต่สังเกตเห็นว่า Apache ก็น่าจะ upgrade เป็นเวอร์ชันใหม่ด้วย ก็เลยทำมันซะทีเดียวพร้อมๆ กัน 3 เครื่อง หลังจาก upgrade เสร็จ ก็ตรวจดูความเรียบร้อยต่างๆ ผมคิดว่าก็น่าจะปกติ ไม่มีปัญหาอะไร
แต่ผลปรากฎว่า ช่วงค่ำๆ ของวันนี้เครื่องอืดผิดปกติ ผมเข้าไปดูก็พบว่า load ของเครื่องปาเข้าไปร้อยกว่าๆ ร้อยกว่าๆ จริงๆ นะครับ ผมเริ่มจากการตรวจสอบเจ้า Apache server ก่อนอื่น และก็พบว่าคงเป็นเจ้า apache นี่แหละที่เป็นตัวปัญหา ผมพยายามหยุด process ก็ไม่ได้ kill process ก็ไม่ได้ ลองอยู่หลายรอบ สุดท้ายก็ต้องสั่ง reboot ผลที่ได้ก็คือสั่ง reboot ก็ไม่ได้เช่นกัน
และด้วยความจำเป็น ผมก็เลยต้องใช้ดัชนีนิ้วชี้กดปุ่ม reset เครื่องก็ทำการ reset ตัวเอง พอเข้ามาถึงช่วงจังหวะของการตรวจสอบ [...]
Tags
.htaccess Apache blogspot CentOS codeigniter CSS domain name driver Drupal Flickr Hotmail HTML internet law linux mailing list mailman MICT mod_rewrite monitor MSL MySQL name server Network open source PHP Postfix Security Smarty sony Spammail SPF theme TLS traffic log Universiade UTF-8 UTF8 vbulletin Wordpress การเมือง จตุคาม รูปภาพ สถิติ เรารักในหลวง
