{"id":2658,"date":"2022-04-22T18:16:33","date_gmt":"2022-04-22T10:16:33","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=2658"},"modified":"2022-04-22T18:16:36","modified_gmt":"2022-04-22T10:16:36","slug":"redirect-http-to-https-htaccess","status":"publish","type":"post","link":"https:\/\/www.intelliwolf.com\/redirect-http-to-https-htaccess\/","title":{"rendered":"How To Redirect HTTP To HTTPS With htaccess"},"content":{"rendered":"\n
On a site I run, we were occasionally having issues with the way plugins were redirecting HTTP requests to HTTPS.<\/p>\n\n\n\n
We were trying to get the most speed out of the site and they were causing load on the database checking whether they should redirect.<\/p>\n\n\n\n
We only had cPanel access, so I did it through .htaccess.<\/p>\n\n\n\n
Pretty much every website now has an SSL certificate. There's no reason to do https to http redirects, so I've just covered the main scenarios you'll come across below.<\/p>\n\n\n\n
If these don't work and you're using an Apache setup (if you're not sure, you're probably using Apache), you may not have the Apache mod_rewrite module<\/a> installed and active.<\/p>\n\n\n\n Edit the .htaccess file in cPanel<\/a> or through FTP<\/a>, edit the .htaccess file in the public_html folder. Add this code to the top:<\/p>\n\n\n\n You can paste that directly, without changing anything.<\/p>\n\n\n\nHow to redirect http to https in .htaccess<\/h2>\n\n\n\n
RewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/code><\/pre>\n\n\n\n