Redirect http to https melalui file htaccess ( www or non www)
Anda dapat melakukan Redirect http to https melalui file htaccess dengan kode berikut di htaccess anda:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Hilangkan kode redirect website anda sebelumnya jika ada, dan tempatkan kode diatas di baris paling awal di htaccess anda ( untuk pengguna cms )
Dan bagi yang ingin mengkombinasikan redirect non www ke www lalu ke https, silakan pergunakan kode berikut:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.+) [NC]
RewriteRule (.*) https://www.%1/$1 [R=301,L]
</IfModule>
RewriteCond %{HTTP_HOST} !^www\.(.+) [NC]
RewriteRule (.*) https://www.%1/$1 [R=301,L]
</IfModule>
0 Response to "Redirect http to https melalui file htaccess"
Post a Comment