cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New

Redirect website to HTTPS in cPanel/Linux

I was able to successfully create the HTTPS URL for my website but the redirect from HTTP still not working. It still comes up as unsecured.  I inserted the code below into my .htaccess file and changed the coolexample to my dns.

 

Is there something else I need to do to get the redirect working? 

 

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?coolexample\.com
RewriteRule ^(.*)$ https://www.coolexample.com/$1 [R,L]

 

1 REPLY 1

Re: Redirect website to HTTPS in cPanel/Linux

I was able to get mine working with what you have down there but I don't have your 2nd line in mine. 
Mine looks like:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://coolexample.com/$1 [R,L]

 

Make sure that if your .HTACCESS file already had stuff in it that you put it where it belongs. Mine already had the rewriteengine on and some other code in there, so you need to drop it between:

 

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://coolexample.com/$1 [R,L]
</IfModule>

# END WordPress

 Please note I put it between the <IfModule>   </IfModule> tags, otherwise it's just text.