Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

how to force https/ssl for an existing domain?

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Locked
  • Print view
Advanced search
8 posts • Page 1 of 1
baijianpeng
Posts: 301
Joined: Tue Dec 22, 2015 2:06 pm

how to force https/ssl for an existing domain?

Post by baijianpeng » Mon Jan 18, 2016 8:24 am

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.
Top

newtron
Posts: 22
Joined: Wed Jan 13, 2016 4:43 pm

Re: how to force https/ssl for an existing domain?

Post by newtron » Mon Jan 18, 2016 10:40 am

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...
Top

baijianpeng
Posts: 301
Joined: Tue Dec 22, 2015 2:06 pm

Re: how to force https/ssl for an existing domain?

Post by baijianpeng » Mon Jan 18, 2016 11:17 am

Ok, I will try the .htaccess method.

Thank you.
Top

baijianpeng
Posts: 301
Joined: Tue Dec 22, 2015 2:06 pm

Re: how to force https/ssl for an existing domain?

Post by baijianpeng » Tue Jan 19, 2016 6:23 am

After some googling, I found following rewrite rule to force SSL with .htaccess:

Code: Select all

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.joomlagate.com/$1 [R,L]
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.
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: how to force https/ssl for an existing domain?

Post by tjebbeke » Tue Jan 19, 2016 7:39 am

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>
Top

baijianpeng
Posts: 301
Joined: Tue Dec 22, 2015 2:06 pm

Re: how to force https/ssl for an existing domain?

Post by baijianpeng » Wed Jan 20, 2016 2:32 am

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.
Top

rizakyo
Posts: 4
Joined: Sat Aug 19, 2017 3:40 am

Re: how to force https/ssl for an existing domain?

Post by rizakyo » Mon Aug 28, 2017 1:15 pm

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?
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: how to force https/ssl for an existing domain?

Post by skurudo » Mon Aug 28, 2017 2:52 pm

rizakyo 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?
Already answered, https://vestacp.com/docs/#how-to-force-https
you can use code from here for nginx.
Top


Locked
  • Print view

8 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password