{"id":30603,"date":"2023-05-31T10:43:37","date_gmt":"2023-05-31T03:43:37","guid":{"rendered":"\/tutorial\/?p=30603"},"modified":"2025-06-03T16:39:00","modified_gmt":"2025-06-03T09:39:00","slug":"force-https-htaccess","status":"publish","type":"post","link":"\/id\/tutorial\/force-https-htaccess","title":{"rendered":"Cara mengaktifkan HTTPS secara paksa menggunakan .htaccess"},"content":{"rendered":"<p>Setelah Anda <a href=\"\/id\/ssl-gratis\">membeli sertifikat SSL<\/a>&nbsp;dan menginstalnya di website, pengunjung bisa mengakses website Anda menggunakan protokol HTTP dan HTTPS.&nbsp;Namun, protokol HTTPS jauh lebih direkomendasikan karena mampu mengenkripsi dan mengamankan data website.<\/p><p>Apabila menggunakan Hostinger, Anda bisa mengonfigurasi pengaturan ini cukup dengan sekali klik, atau menerapkan aturan force HTTP melalui file <strong>.htaccess<\/strong>. Nah, tutorial ini akan menjelaskan langkah-langkahnya lebih lanjut. Yuk, simak selengkapnya!<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Speed-Up-Your-Website-ID.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2022\/11\/eBook-Speed-Up-website-ID.png\/public\" alt=\"\" class=\"wp-image-27589\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2022\/11\/eBook-Speed-Up-website-ID.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2022\/11\/eBook-Speed-Up-website-ID.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2022\/11\/eBook-Speed-Up-website-ID.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2022\/11\/eBook-Speed-Up-website-ID.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-force-https-untuk-seluruh-traffic\">Force HTTPS untuk seluruh traffic<\/h2><p>Salah satu fungsi yang bisa Anda lakukan melalui&nbsp;<strong>.htaccess<\/strong>&nbsp;adalah 301 redirect, yang secara permanen mengalihkan URL lama ke URL baru.&nbsp;Anda bisa mengaktifkan fitur ini untuk force HTTPS pada semua traffic yang masuk. Berikut caranya:<\/p><ol class=\"wp-block-list\">\n<li>Buka&nbsp;<strong>File Manager<\/strong>&nbsp;di control panel hosting Anda, lalu buka&nbsp;<strong>.htaccess<\/strong>&nbsp;di folder <strong>public_html<\/strong>.&nbsp;Kalau Anda tidak bisa menemukannya, <a href=\"\/id\/tutorial\/cara-membuat-file-htaccess-wordpress-default\">buat file .htaccess lalu atur visibilitasnya<\/a>.<\/li>\n\n\n\n<li>Scroll ke bawah untuk menemukan&nbsp;<strong>RewriteEngine On<\/strong>&nbsp;dan masukkan baris kode berikut di bawahnya:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">RewriteEngine On \nRewriteCond %{HTTPS} off \nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Simpan<\/strong> perubahan.<\/li>\n<\/ol><p>\n\n\n<div><p class=\"important\"><strong>Penting!<\/strong> Pastikan baris <strong>RewriteEngine On<\/strong> tidak diulang dua kali. Apabila baris tersebut sudah ada, cukup salin kode lainnya tanpa menyertakannya.<\/p><\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-force-https-pada-domain-tertentu\">Force HTTPS pada domain tertentu<\/h2><p>Misalnya Anda memiliki dua domain:&nbsp;<strong>http:\/\/domainanda1.com<\/strong>&nbsp;dan&nbsp;<strong>http:\/\/domainanda2.com<\/strong>.&nbsp;Keduanya akan mengarah ke website yang sama, tapi Anda ingin yang pertama dialihkan ke versi HTTPS.&nbsp;Dalam hal ini, Anda perlu menggunakan kode berikut:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">RewriteEngine On \nRewriteCond %{HTTP_HOST} ^yourdomain1.com [NC] \nRewriteCond %{HTTPS} off \nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]<\/pre><p>Pastikan untuk mengganti&nbsp;<strong>yourdomain1<\/strong>&nbsp;dengan domain yang Anda miliki untuk force HTTPS <strong>.htaccess<\/strong>.<\/p><h2 class=\"wp-block-heading\" id=\"h-force-https-pada-folder-tertentu\">Force HTTPS pada folder tertentu<\/h2><p>File&nbsp;<strong>.htaccess<\/strong>&nbsp;juga bisa digunakan untuk force HTTPS pada folder tertentu.&nbsp;Namun, file tersebut harus ditempatkan di folder yang memiliki koneksi HTTPS.<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">RewriteEngine On \nRewriteCond %{HTTPS} off \nRewriteRule ^(folder1|folder2|folder3) https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]<\/pre><p>Pastikan untuk mengubah nama <strong>folder<\/strong>&nbsp;menjadi nama direktori Anda sebenarnya.<\/p><p>Setelah melakukan perubahan, clear cache browser dan coba akses website Anda melalui HTTP.&nbsp;Kalau langkah-langkahnya dilakukan dengan benar, browser akan mengarahkan Anda ke versi HTTPS.<\/p><figure class=\"wp-block-image size-large\"><a href=\"\/id\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2023\/02\/ID-Web-hosting_in-text-banner.png\/public\" alt=\"\" class=\"wp-image-29634\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2023\/02\/ID-Web-hosting_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2023\/02\/ID-Web-hosting_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2023\/02\/ID-Web-hosting_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/37\/2023\/02\/ID-Web-hosting_in-text-banner.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-kesimpulan\">Kesimpulan<\/h2><p>Selamat!&nbsp;Anda sudah berhasil mengedit&nbsp;<strong>file .htaccess<\/strong>&nbsp;dan mengalihkan semua traffic HTTP ke HTTPS sebagai versi yang lebih aman.<\/p><p>Tergantung pada platform website Anda, mungkin ada metode lain untuk mengaktifkan fitur ini.&nbsp;Misalnya, Anda bisa mengonfigurasi website WordPress atau PrestaShop untuk menggunakan HTTPS menggunakan plugin.<\/p><p>Kalau Anda memiliki tips, trik, atau saran yang ingin dibagikan, jangan ragu untuk menyampaikannya lewat komentar, ya!<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Saran bacaan<\/h4>\n                    <p><a href=\"\/id\/tutorial\/perbedaan-http-dan-https\">Perbedaan HTTP dan HTTPS, kelebihan, dan kekurangannya<\/a><br>\n<a href=\"\/id\/tutorial\/cara-mengatasi-mixed-content-wordpress\">Cara mengatasi error mixed content di WordPress<\/a><br>\n<a href=\"\/id\/tutorial\/cara-redirect-301\">Cara redirect 301 di WordPress<\/a><\/p>\n                <\/div>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setelah Anda membeli sertifikat SSL&nbsp;dan menginstalnya di website, pengunjung bisa mengakses website Anda menggunakan protokol HTTP dan HTTPS.&nbsp;Namun, protokol HTTPS jauh lebih direkomendasikan karena mampu mengenkripsi dan mengamankan data website. Apabila menggunakan Hostinger, Anda bisa mengonfigurasi pengaturan ini cukup dengan sekali klik, atau menerapkan aturan force HTTP melalui file .htaccess. Nah, tutorial ini akan menjelaskan [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/id\/tutorial\/force-https-htaccess\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":190,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"Cara force HTTPS menggunakan file .htaccess","rank_math_description":"Mengaktifkan HTTPS merupakan langkah penting untuk menjaga keamanan online Anda. Baca cara force HTTPS htaccess lengkap di artikel ini!","rank_math_focus_keyword":"force https htaccess","footnotes":""},"categories":[9432],"tags":[],"class_list":["post-30603","post","type-post","status-publish","format-standard","hentry","category-lainnya"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/force-https-using-htaccess","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-forcar-acesso-ssl-em-meu-site","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/comment-forcer-le-https-a-laide-de-htaccess","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-forzar-https-usando-htaccess","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/force-https-htaccess","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/force-https-using-htaccess","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/ssl\/force-https-using-htaccess","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/ssl\/force-https-using-htaccess","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-forzar-https-usando-htaccess","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-forzar-https-usando-htaccess","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-forzar-https-usando-htaccess","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-forcar-acesso-ssl-em-meu-site","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/force-https-using-htaccess","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/force-https-using-htaccess","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/force-https-using-htaccess","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/force-https-using-htaccess","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/posts\/30603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/users\/190"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/comments?post=30603"}],"version-history":[{"count":10,"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/posts\/30603\/revisions"}],"predecessor-version":[{"id":44573,"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/posts\/30603\/revisions\/44573"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/media?parent=30603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/categories?post=30603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/id\/tutorial\/wp-json\/wp\/v2\/tags?post=30603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}