3 ways to force secure https by .htaccess
by David Pham • January 26, 2015 • Blog
There are some ways to Force secure https by .htaccess when you do the PHP programming apps. These ways you can use for almost your PHP web on Zend Framework or Codeigniter.
1. Force secure https by .htaccess with domain
1 2 3 |
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.com/$1 [R,L] |
2. Force secure https by .htaccess without domain name
1 2 3 4 |
RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L] |
3. Force secure https by .htaccess with domain and port
1 2 3 |
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L] |