SOLVED http to https redirect

'Giovanni

Member
Feb 13, 2008
9
1
51
i want to redirect all http non www and www to https with www, for example
Code:
domain.com to https://www.domain.com
www.domain.com to https://www.domain.com
https://domain.com to https://www.domain.com
anyone can help?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
Hello,

Could you post the contents of the .htaccess file you tried using, ensuring to replace real domain names with examples?

Thank you.
 

'Giovanni

Member
Feb 13, 2008
9
1
51
my .htaccess was empty.
i put the code that was specified in your links and replaced domain.com with my real domain.

for now i've found a working solution:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
i'm not sure if this is correct but it gets the job done, it points all my non https with or without www to ssl with www.
 
  • Like
Reactions: cPanelMichael

theluli

Member
Nov 19, 2015
12
2
53
Kosovo
cPanel Access Level
DataCenter Provider
my .htaccess was empty.
i put the code that was specified in your links and replaced domain.com with my real domain.

for now i've found a working solution:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
i'm not sure if this is correct but it gets the job done, it points all my non https with or without www to ssl with www.
Hi Giovanni

Where you add this "domain" does has to be a real domain name and second , you need to add for all domains ?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,216
463
Where you add this "domain" does has to be a real domain name and second , you need to add for all domains ?
Hello @theluli,

Yes, it should be a real domain name. You should only have to add it to the document root of the domain name you want redirected.

Thank you.