Force Https CentOS Web Panel
5,624
I have found out that using the .htaccess
is the easiest method to solve the problem.
Adding the below mentioned codes in .htaccess
gives the solution:
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://www.yourdomain.com%{REQUEST_URI} [NS,R,L]
If there is any other easiest method than .htaccess
redirection exists anyone could help edit this answer.
Author by
PaladiN
Updated on September 18, 2022Comments
-
PaladiN over 1 year
I am using
CentOS Web Panel
and trying to redirect tohttps
also when someone hits thehttp
link. I am only able to open bothhttps
when i typehttps://domain.com
.Using the below rules solves my problem
RewriteEngine On RewriteCond %{SERVER_PORT} !=443 RewriteRule ^ https://www.yourdomain.com%{REQUEST_URI} [NS,R,L]
But i need to add this to all the sites in my server.
How can i automatically redirect all the sites in my server?
Does any method other than
.htaccess redirection
exists to redirect to https?Hope i have clearly stated the problem.
-
Admin over 7 yearsIn order to do that you need to add the rule directly to the apache config file and not in .htaccess where it will be more global and not directory specific. You will also need to use the
HTTP_HOST
var instead of the domain name if you want it to work for other sites.
-