{"id":4881,"date":"2023-03-16T16:55:00","date_gmt":"2023-03-16T21:55:00","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4881"},"modified":"2023-03-16T12:23:13","modified_gmt":"2023-03-16T17:23:13","slug":"redirect-website-http-to-https-using-the-htaccess-file","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/redirect-website-http-to-https-using-the-htaccess-file\/","title":{"rendered":"Redirect website HTTP to HTTPS using the .htaccess file"},"content":{"rendered":"\n<p>The following can be added to the .htaccess file to redirect all http request to https.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On\nRewriteCond %{HTTPS} off  \nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]<\/pre>\n\n\n\n<p>RewriteEngine On &#8211; Allows the rewrite capabilities.  If it was off, the last rule &#8220;RewriteRule&#8221; would not work.<br>RewriteCond &#8211; This is a conditional that says if the current request is using HTTPS, don&#8217;t rewrite.  If this option was not here, we would get an infinite redirect loop.<br>RewriteRule &#8211; This is the actual rule that rewrites or redirects any HTTP request to HTTPS.  the R=301 means that it redirects using a 301 status code.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The following links provide more detail and info on htaccess redirects.<\/p>\n\n\n\n<p><a href=\"https:\/\/linuxize.com\/post\/htaccess-force-https\/\">https:\/\/linuxize.com\/post\/htaccess-force-https\/<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.redhat.com\/sysadmin\/beginners-guide-redirects-htaccess\">https:\/\/www.redhat.com\/sysadmin\/beginners-guide-redirects-htaccess<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following can be added to the .htaccess file to redirect all http request to https. RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteEngine On &#8211; Allows the rewrite capabilities. If it was off, the last rule &#8220;RewriteRule&#8221; &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/redirect-website-http-to-https-using-the-htaccess-file\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1057,1415,1417,1418,1416],"class_list":["post-4881","post","type-post","status-publish","format-standard","hentry","category-linux","tag-hosting","tag-htaccess","tag-request","tag-rewriterule","tag-web"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4881"}],"version-history":[{"count":1,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4881\/revisions"}],"predecessor-version":[{"id":4882,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4881\/revisions\/4882"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}