{"id":25072,"date":"2022-02-02T15:03:31","date_gmt":"2022-02-02T15:03:31","guid":{"rendered":"https:\/\/1-grid.com\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/"},"modified":"2023-03-17T05:51:54","modified_gmt":"2023-03-17T05:51:54","slug":"apache-redirect-http-to-https-using-mod_rewrite","status":"publish","type":"ht_kb","link":"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/","title":{"rendered":"Apache Redirect HTTP to HTTPS using mod_rewrite"},"content":{"rendered":"<blockquote><p><span style=\"color: #000000;\">This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite<\/span><\/p><\/blockquote>\n<p><span style=\"font-family: Helvetica, sans-serif; font-size: 12px; color: #000000;\">Apache\u2019s mod_rewrite makes it easy to require SSL to be used on your site and to gently redirect users who forget to add the https when typing the URL. Using Apache to redirect http to https will make sure that your site (or a part of it) will only be accessed by your customers using SSL. \u00a0This is good because users often forget to type in the https and will be automatically redirected.<\/span><\/p>\n<p><span style=\"font-size: 12px;\"><span style=\"font-family: Helvetica,sans-serif;\">\u00a0<\/span><\/span><\/p>\n<p><span style=\"font-size: 12px;\"><span style=\"font-family: Helvetica,sans-serif;\">\u00a0<\/span><\/span><\/p>\n<p><span style=\"font-size: 12px; color: #000000;\"><span style=\"font-family: Helvetica,sans-serif;\">Before you can set up an Apache redirect from http to https, you will need to do the following:<\/span><\/span><\/p>\n<ul>\n<li><span style=\"font-size: 12px;\"><span style=\"font-family: Helvetica,sans-serif;\"><span style=\"color: #000000;\">Make sure your SSL certificate is successfully installed so you can access<\/span> <a href=\"https:\/\/www.yoursite.com\" rel=\"noreferrer\">https:\/\/www.yoursite.com<\/a> <span style=\"color: #000000;\">(for more information see our\u00a0Apache SSL Installation instructions)<\/span><\/span><\/span><\/li>\n<li><span style=\"font-size: 12px; color: #000000;\"><span style=\"font-family: Helvetica,sans-serif;\">Make sure mod_rewrite is enabled in Apache<\/span><\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 12px; color: #000000;\"><span style=\"font-family: Helvetica,sans-serif;\">Now you just need to edit your httpd.conf file or the file where your virtual host is specified and add these lines to redirect http to https:<\/span><\/span><\/p>\n<p><span style=\"font-size: 12px;\">\u00a0<\/span><\/p>\n<pre><span style=\"font-family: Helvetica,sans-serif;\"><span style=\"font-size: 12px;\">RewriteEngine On<\/span><br style=\"box-sizing: border-box;\" \/>RewriteCond %{HTTPS} off<br style=\"box-sizing: border-box;\" \/>RewriteRule (.*) https:\/\/%{SERVER_NAME}\/$1 [R,L]<\/span><\/pre>\n<p><span style=\"font-family: Helvetica, sans-serif; font-size: 12px; color: #000000;\">In many cases, you can also just add those lines to a file named .htaccess in the folder that you want to redirect http to https.<\/span><\/p>\n<p><span style=\"font-size: 12px;\"><span style=\"font-family: Helvetica,sans-serif;\"><span style=\"color: #000000;\">Now, when a visitor types<\/span> <a href=\"http:\/\/www.yoursite.com\/mypage.htm\" rel=\"noreferrer\">http:\/\/www.yoursite.com\/mypage.htm<\/a> <span style=\"color: #000000;\">the server will automatically redirect http to https so that they go to<\/span> <a href=\"https:\/\/www.yoursite.com\/mypage.htm\" rel=\"noreferrer\">https:\/\/www.yoursite.com\/mypage.htm<\/a><\/span><\/span><\/p>\n<p><span style=\"font-family: Helvetica, sans-serif; font-size: 12px; color: #000000;\"><strong>Note:<\/strong> You can also redirect a single page from http to https in Apache by using this in your configuration file or .htaccess file:<\/span><\/p>\n<pre><span style=\"font-family: Helvetica,sans-serif;\">RewriteEngine On<br style=\"box-sizing: border-box;\" \/>RewriteRule ^apache-redirect-http-to-https.html$ https:\/\/www.yoursite.com\/apache-redirect-http-to-https.html [R=301,L]<\/span><\/pre>\n<p><span style=\"font-family: Helvetica, sans-serif; font-size: 12px; color: #000000;\"><strong>TIP:\u00a0<\/strong>All cPanel servers in our environment runs Apache so this script can be added to the .htaccess file inside your File manager.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite Apache\u2019s mod_rewrite makes it easy to require SSL to be used on your site and to gently redirect users who forget to add the https when typing the URL. Using Apache to redirect&#8230;<\/p>\n","protected":false},"author":21,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"ht-kb-category":[21],"ht-kb-tag":[97,480,492,493,638,821,1333,951,1024,1086],"class_list":["post-25072","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-ssl-certificates","ht_kb_tag-apache","ht_kb_tag-how-to","ht_kb_tag-http","ht_kb_tag-https","ht_kb_tag-mod","ht_kb_tag-redirect","ht_kb_tag-rewrite","ht_kb_tag-ssl-certificates-and-website-security","ht_kb_tag-to","ht_kb_tag-using"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Apache Redirect HTTP to HTTPS using mod_rewrite -<\/title>\n<meta name=\"description\" content=\"This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite 1-grid Knowledge Base\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apache Redirect HTTP to HTTPS using mod_rewrite -\" \/>\n<meta property=\"og:description\" content=\"This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite 1-grid Knowledge Base\" \/>\n<meta property=\"og:url\" content=\"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/\" \/>\n<meta property=\"og:site_name\" content=\"1-grid Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/1grid.co.za\/\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-17T05:51:54+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@1grid_hosting\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/\",\"name\":\"Apache Redirect HTTP to HTTPS using mod_rewrite -\",\"isPartOf\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#website\"},\"datePublished\":\"2022-02-02T15:03:31+00:00\",\"dateModified\":\"2023-03-17T05:51:54+00:00\",\"description\":\"This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite 1-grid Knowledge Base\",\"breadcrumb\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/1grid.co.za\/knowledge\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apache Redirect HTTP to HTTPS using mod_rewrite\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#website\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/\",\"name\":\"1-Grid Domain Hosting Knowledge Base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/1grid.co.za\/knowledge\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#organization\",\"name\":\"1-Grid Domain Hosting Knowledge Base\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg\",\"contentUrl\":\"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg\",\"width\":100,\"height\":100,\"caption\":\"1-Grid Domain Hosting Knowledge Base\"},\"image\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/1grid.co.za\/\",\"https:\/\/twitter.com\/1grid_hosting\",\"https:\/\/www.instagram.com\/1grid_hosting\/\",\"https:\/\/za.linkedin.com\/company\/1-grid\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apache Redirect HTTP to HTTPS using mod_rewrite -","description":"This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite 1-grid Knowledge Base","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:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/","og_locale":"en_US","og_type":"article","og_title":"Apache Redirect HTTP to HTTPS using mod_rewrite -","og_description":"This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite 1-grid Knowledge Base","og_url":"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/","og_site_name":"1-grid Knowledge Base","article_publisher":"https:\/\/www.facebook.com\/1grid.co.za\/","article_modified_time":"2023-03-17T05:51:54+00:00","twitter_card":"summary_large_image","twitter_site":"@1grid_hosting","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/","url":"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/","name":"Apache Redirect HTTP to HTTPS using mod_rewrite -","isPartOf":{"@id":"https:\/\/1grid.co.za\/knowledge\/#website"},"datePublished":"2022-02-02T15:03:31+00:00","dateModified":"2023-03-17T05:51:54+00:00","description":"This article provides you with information on how to redirect your website to HTTPS via Apache mod_rewrite 1-grid Knowledge Base","breadcrumb":{"@id":"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/1grid.co.za\/knowledge\/apache-redirect-http-to-https-using-mod_rewrite\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/1grid.co.za\/knowledge\/"},{"@type":"ListItem","position":2,"name":"Apache Redirect HTTP to HTTPS using mod_rewrite"}]},{"@type":"WebSite","@id":"https:\/\/1grid.co.za\/knowledge\/#website","url":"https:\/\/1grid.co.za\/knowledge\/","name":"1-Grid Domain Hosting Knowledge Base","description":"","publisher":{"@id":"https:\/\/1grid.co.za\/knowledge\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/1grid.co.za\/knowledge\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/1grid.co.za\/knowledge\/#organization","name":"1-Grid Domain Hosting Knowledge Base","url":"https:\/\/1grid.co.za\/knowledge\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/","url":"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg","contentUrl":"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg","width":100,"height":100,"caption":"1-Grid Domain Hosting Knowledge Base"},"image":{"@id":"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/1grid.co.za\/","https:\/\/twitter.com\/1grid_hosting","https:\/\/www.instagram.com\/1grid_hosting\/","https:\/\/za.linkedin.com\/company\/1-grid"]}]}},"_links":{"self":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/25072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/comments?post=25072"}],"version-history":[{"count":2,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/25072\/revisions"}],"predecessor-version":[{"id":30952,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/25072\/revisions\/30952"}],"wp:attachment":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/media?parent=25072"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb-category?post=25072"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb-tag?post=25072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}