{"id":6413,"date":"2019-03-20T12:14:24","date_gmt":"2019-03-20T12:14:24","guid":{"rendered":"https:\/\/www.milesweb.in\/hosting-faqs\/?p=6413"},"modified":"2019-03-20T12:14:24","modified_gmt":"2019-03-20T12:14:24","slug":"force-ssl-using-htaccess","status":"publish","type":"post","link":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/","title":{"rendered":"Steps to Force SSL Using the .htaccess"},"content":{"rendered":"<p>SSL certificate plays a significant role on your website. It helps to build the trust of your visitors as well as encrypts the data that is shared by your customers on your website. The data such as a customer\u2019s personal details, credit\/debit card information, bank details, etc. is secured with SSL. Additionally, having the SSL certificate installed on your website also helps in boosting your website\u2019s ranking in the search engines.<\/p>\n<p>So, the visitors on your website should be accessing it using an SSL-encrypted connection for additional security, accessibility or PCI compliance.<\/p>\n<p>MilesWeb offers SSL certificate with its entire web hosting plans. You can activate this SSL in your <strong>Account Management Panel (AMP) <\/strong>under <strong>My Account &gt; Manage Free SSL<\/strong>.<\/p>\n<p>You can force visitors to use SSL through your .htaccess file using mod_rewrite.<\/p>\n<h3>Forcing HTTPS with .htaccess<\/h3>\n<h3>1. Redirect All Web Traffic<\/h3>\n<p>If you want to force all web traffic to use SSL certificate, run the following code in the .htaccess file in your website&#8217;s root folder.<\/p>\n<p><strong>NOTE:<\/strong> If there is an existing code in your .htaccess, add this code above where you will find rules with a similar starting prefix. If there are any issues afterwards, move the new code below some elements &#8211; e.g. Options +FollowSymLinks.<\/p>\n<pre class=\"lang:default decode:true \">RewriteEngine On\r\nRewriteCond %{HTTPS} !on\r\nRewriteCond %{REQUEST_URI} !^\/[0-9]+\\..+\\.cpaneldcv$\r\nRewriteCond %{REQUEST_URI} !^\/\\.well-known\/pki-validation\/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$\r\nRewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/pre>\n<h3>2. Redirect Only Specified Domain<\/h3>\n<p>In order to force a specific domain for using HTTPS, you can use the below code in the .htaccess file in your website&#8217;s root folder:<\/p>\n<p><strong>NOTE:<\/strong> If there is an existing code in your .htaccess, add this code above where you will find rules with a similar starting prefix. If there are any issues afterwards, move the new code below some elements &#8211; e.g. Options +FollowSymLinks.<\/p>\n<pre class=\"lang:default decode:true \">RewriteCond %{REQUEST_URI} !^\/[0-9]+\\..+\\.cpaneldcv$\r\nRewriteCond %{REQUEST_URI} !^\/\\.well-known\/pki-validation\/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$\r\nRewriteEngine On\r\nRewriteCond %{HTTP_HOST} ^example\\.com [NC]\r\nRewriteCond %{SERVER_PORT} 80\r\nRewriteRule ^(.*)$ https:\/\/www.example.com\/$1 [R=301,L]<\/pre>\n<p>If the above code isn\u2019t working, remove the first two lines and run the code as below:<\/p>\n<pre class=\"lang:default decode:true \">RewriteEngine On\r\nRewriteCond %{HTTP_HOST} ^example\\.com [NC]\r\nRewriteCond %{SERVER_PORT} 80\r\nRewriteRule ^(.*)$ https:\/\/www.example.com\/$1 [R=301,L]<\/pre>\n<p>Ensure that you replace example.com with the domain name for which you are forcing https. Also, you need to replace www.example.com with your actual domain name.<\/p>\n<h3>3. Redirect Specified Folder<\/h3>\n<p>In case you want to force SSL on a specific folder, input the below code into a .htaccess file that is placed in that particular folder:<\/p>\n<p><strong>NOTE:<\/strong> If there is an existing code in your .htaccess, add this code above where you will find rules with a similar starting prefix. If there are any issues afterwards, move the new code below some elements &#8211; e.g. Options +FollowSymLinks.<\/p>\n<pre class=\"lang:default decode:true \">RewriteCond %{REQUEST_URI} !^\/[0-9]+\\..+\\.cpaneldcv$\r\nRewriteCond %{REQUEST_URI} !^\/\\.well-known\/pki-validation\/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$\r\nRewriteEngine On\r\nRewriteCond %{SERVER_PORT} 80\r\nRewriteCond %{REQUEST_URI} folder\r\nRewriteRule ^(.*)$ https:\/\/www.example.com\/folder\/$1 [R=301,L]<\/pre>\n<p>Ensure that you change the folder reference to the original folder name. Then make sure to replace www.example.com\/folderwith your original domain name and folder, you want to force the SSL on.<\/p>\n<p>In this way, you can easily force SSL on any website using the .htaccess.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SSL certificate plays a significant role on your website. It helps to build the trust of your visitors as well as encrypts the data that is shared by your customers on your website. The data such as a customer\u2019s personal details, credit\/debit card information, bank details, etc. is secured with SSL. Additionally, having the SSL [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":6448,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[615,339,64],"class_list":["post-6413","post","type-post","status-publish","format-standard","has-post-thumbnail","placeholder-for-hentry","category-ssl-issues-faq","tag-force-ssl","tag-https","tag-ssl-certificate"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Simple Steps to Force SSL Using .htaccess File<\/title>\n<meta name=\"description\" content=\"SSL plays a vital role in securing your website. The article reveals steps to force SSL certificate on any website using the .htaccess file.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simple Steps to Force SSL Using .htaccess File\" \/>\n<meta property=\"og:description\" content=\"SSL plays a vital role in securing your website. The article reveals steps to force SSL certificate on any website using the .htaccess file.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-20T12:14:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"445\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Pallavi Godse\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pallavi Godse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/\"},\"author\":{\"name\":\"Pallavi Godse\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\"},\"headline\":\"Steps to Force SSL Using the .htaccess\",\"datePublished\":\"2019-03-20T12:14:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/\"},\"wordCount\":458,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png\",\"keywords\":[\"force SSL\",\"HTTPS\",\"SSL certificate\"],\"articleSection\":[\"SSL Issues &amp; FAQ\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/\",\"name\":\"Simple Steps to Force SSL Using .htaccess File\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png\",\"datePublished\":\"2019-03-20T12:14:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\"},\"description\":\"SSL plays a vital role in securing your website. The article reveals steps to force SSL certificate on any website using the .htaccess file.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png\",\"contentUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png\",\"width\":800,\"height\":445},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Steps to Force SSL Using the .htaccess\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\",\"name\":\"Pallavi Godse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3602d0ac1ab89332aea8205dcf474af4ff4eb319cfd584544038908cd5e4c966?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3602d0ac1ab89332aea8205dcf474af4ff4eb319cfd584544038908cd5e4c966?s=96&d=blank&r=g\",\"caption\":\"Pallavi Godse\"},\"description\":\"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.\",\"sameAs\":[\"https:\/\/www.milesweb.in\"],\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/author\/pallavi\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Simple Steps to Force SSL Using .htaccess File","description":"SSL plays a vital role in securing your website. The article reveals steps to force SSL certificate on any website using the .htaccess file.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/","og_locale":"en_US","og_type":"article","og_title":"Simple Steps to Force SSL Using .htaccess File","og_description":"SSL plays a vital role in securing your website. The article reveals steps to force SSL certificate on any website using the .htaccess file.","og_url":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2019-03-20T12:14:24+00:00","og_image":[{"width":800,"height":445,"url":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png","type":"image\/png"}],"author":"Pallavi Godse","twitter_misc":{"Written by":"Pallavi Godse","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#article","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/"},"author":{"name":"Pallavi Godse","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945"},"headline":"Steps to Force SSL Using the .htaccess","datePublished":"2019-03-20T12:14:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/"},"wordCount":458,"commentCount":0,"image":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png","keywords":["force SSL","HTTPS","SSL certificate"],"articleSection":["SSL Issues &amp; FAQ"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/","url":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/","name":"Simple Steps to Force SSL Using .htaccess File","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage"},"image":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png","datePublished":"2019-03-20T12:14:24+00:00","author":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945"},"description":"SSL plays a vital role in securing your website. The article reveals steps to force SSL certificate on any website using the .htaccess file.","breadcrumb":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#primaryimage","url":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png","contentUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/03\/steps-to-force-SSL-Using-the-htaccess.png","width":800,"height":445},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/force-ssl-using-htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.in\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"Steps to Force SSL Using the .htaccess"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.in\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945","name":"Pallavi Godse","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3602d0ac1ab89332aea8205dcf474af4ff4eb319cfd584544038908cd5e4c966?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3602d0ac1ab89332aea8205dcf474af4ff4eb319cfd584544038908cd5e4c966?s=96&d=blank&r=g","caption":"Pallavi Godse"},"description":"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.","sameAs":["https:\/\/www.milesweb.in"],"url":"https:\/\/www.milesweb.in\/hosting-faqs\/author\/pallavi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=6413"}],"version-history":[{"count":3,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6413\/revisions"}],"predecessor-version":[{"id":6449,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6413\/revisions\/6449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/media\/6448"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=6413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=6413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=6413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}