We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
how to force https/ssl for an existing domain?
-
- Posts: 301
- Joined: Tue Dec 22, 2015 2:06 pm
how to force https/ssl for an existing domain?
I had set up hosting plans with "default" template and created website with an domain.
Then, after some time, I know that HTTPS is good. Then I applied SSL certificate and installed them.
Now my website can be open by https protocol, but if someone use "http" to visit, it also opened without SSL.
I tried the "force https/ssl" trick in VestaCP Documentation, but it seems only work for "new domains", not for "existing domains".
So, what should I do now to configure my existing domain to force HTTPS/SSL access?
Thank you.
Then, after some time, I know that HTTPS is good. Then I applied SSL certificate and installed them.
Now my website can be open by https protocol, but if someone use "http" to visit, it also opened without SSL.
I tried the "force https/ssl" trick in VestaCP Documentation, but it seems only work for "new domains", not for "existing domains".
So, what should I do now to configure my existing domain to force HTTPS/SSL access?
Thank you.
Re: how to force https/ssl for an existing domain?
You can use .htaccess, PHP "header" function or use this -> https://vestacp.com/docs/#how-to-force-https
I recomend the .hta and php options...
I recomend the .hta and php options...
-
- Posts: 301
- Joined: Tue Dec 22, 2015 2:06 pm
Re: how to force https/ssl for an existing domain?
Ok, I will try the .htaccess method.
Thank you.
Thank you.
-
- Posts: 301
- Joined: Tue Dec 22, 2015 2:06 pm
Re: how to force https/ssl for an existing domain?
After some googling, I found following rewrite rule to force SSL with .htaccess:
This will force https for ALL urls of my domain. However, I only want to force https for "www.joomlagate.com/***", NOT for some subdomains like "file.joomlagate.com" or "ftp.joomlagate.com", how to modify this rule to ONLY work for main domains but not for subdomains?
Thank you.
Code: Select all
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.joomlagate.com/$1 [R,L]
Thank you.
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: how to force https/ssl for an existing domain?
You can try this:
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !localhost
RewriteCond %{HTTP_HOST} !sub.domain.com
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]
</IfModule>
-
- Posts: 301
- Joined: Tue Dec 22, 2015 2:06 pm
Re: how to force https/ssl for an existing domain?
Thank you.
Finally I realised that my issue should not be solved in this way. I should use CA certificate instead of self-made (openssl by VestaCP) certificate.
Finally I realised that my issue should not be solved in this way. I should use CA certificate instead of self-made (openssl by VestaCP) certificate.
Re: how to force https/ssl for an existing domain?
I believe that .htaccess is belong to apache. Unfortunately I am only using nginx on my VestaCP. Is there anyway to force the use of https on my website?
Re: how to force https/ssl for an existing domain?
Already answered, https://vestacp.com/docs/#how-to-force-httpsrizakyo wrote:I believe that .htaccess is belong to apache. Unfortunately I am only using nginx on my VestaCP. Is there anyway to force the use of https on my website?
you can use code from here for nginx.