Htaccess redirect http to https

Code redirect website về https cho tất cả các domain hay chỉ một vài domain bạn muốn

Htaccess redirect all to https

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Code bên trên sẽ chuyển tất cả yêu cầu về https

Htaccess redirect some domain to https

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(thietkewebbienhoa)\.vn$ [NC]
RewriteRule ^ https://%1.vn%{REQUEST_URI} [R=302,L,NE]

Code này sẽ chỉ chuyển tên miền thietkewebbienhoa.vn về https://thietkewebbienhoa.vn

Bonus cho ai muốn tăng tốc cache các file cho website google

<filesMatch ".(jpg|jpeg|png|gif|ico|ttf|woff|woff2|eot|svg)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>

Chúc vui - Thanhansoft

Tin tức khác