cancel
Showing results for 
Search instead for 
Did you mean: 
Go to solution
edz
Novice

Http to Https redirect for subdomains working

Here is an easy way to have your subdomain automatically change someone coming in  with HTTP over to HTTPS to have a secure connection.

 

With CentOS-6 change to the "/etc/httpd/conf.d" directory.  - Then edit your ssl.conf file. - Once the ssl.conf file has been edited, you need to stop and restart the httpd service using the "service httpd restart" command.  - In the example the subdomain is "abc"  the domain is yourdomain.com   - Please note in the example the "crt" file has a bogus hex number.  - You have to get your own "crt" during the SSL registration process.  -  What the example does if someone comes in under port 80 for the subdomain, they are redirected to the HTTPS method. 

 

= = = = = = = = = = = = = Start Example = = = = = = = = = = = = =

# Change made 2018-03-26 by Edz . . .
<VirtualHost *:80>
    ServerName  abc.yourdomain.com
    Redirect / https://abc.yourdomain.com/
</VirtualHost>

# Change made 2018-03-24 by Edz . . .
 <VirtualHost *:443>
        ServerName  abc.yourdomain.com
        ServerAlias   abc.yourdomain.com
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/3e267fc58f8a1b20.crt
SSLCertificateKeyFile /etc/pki/tls/private/yourdomain.key
SSLCACertificateFile /etc/pki/tls/certs/gd_bundle-g2-g1.crt
        DocumentRoot  /var/www/html/abc/
</VirtualHost>

= = = = = = = = = = = = = End Example = = = = = = = = = = = = =

 

Enjoy. . . .

--

 

4 REPLIES
Pro Community Founder Artisan Pro Community Founder Artisan
Pro Community Founder Artisan

Re: Http to Https redirect for subdomains working

Thank you for contributing this solution @edz. Do you have the information on how to handle this issue for those not on CentOS?

...turns out that my two cents is worth less or more depending on the current exchange rate.

roy darling *my posts seem a lot shorter in my head

edz
Novice
Solution

Re: Http to Https redirect for subdomains working

Hello Roy,

 

The information I came across originated from Apache, so it seems logical it should work on other versions / brands of Linux.  

 

If you have an ssl.conf, make a copy of that file then edited the way I did.  Once done you will have to stop and restart the Apache server.

 

Then try it out to see if it works.

 

Here are some clues on restarting Apache:

https://www.cyberciti.biz/faq/star-stop-restart-apache2-webserver/

 

= = = = = = = = = = = = = = = = = = = = = =

 

Here is an easy way to have your subdomain automatically change someone coming in  with HTTP over to HTTPS to have a secure connection.

 

With CentOS-6 change to the "/etc/httpd/conf.d" directory.  - Then edit your ssl.conf file. - Once the ssl.conf file has been edited, you need to stop and restart the httpd service using the "service httpd restart" command.  - In the example the subdomain is "abc"  the domain is yourdomain.com   - Please note in the example the "crt" file has a bogus hex number.  - You have to get your own "crt" during the SSL registration process.  -  What the example does if someone comes in under port 80 for the subdomain, they are redirected to the HTTPS method.

 

= = = = = = = = = = Start Example = = = = = = = = = = = = =

 

# Change made 2018-03-26 by Edz . . .

<VirtualHost *:80>

    ServerName  abc.yourdomain.com

    Redirect / https://abc.yourdomain.com/

</VirtualHost>

 

# Change made 2018-03-24 by Edz . . .

 <VirtualHost *:443>

        ServerName  abc.yourdomain.com

        ServerAlias   abc.yourdomain.com

SSLEngine on

SSLCertificateFile /etc/pki/tls/certs/3e267fc58f8a1b20.crt

SSLCertificateKeyFile /etc/pki/tls/private/yourdomain.key

SSLCACertificateFile /etc/pki/tls/certs/gd_bundle-g2-g1.crt

        DocumentRoot  /var/www/html/abc/

</VirtualHost>

 

= = = = = = = = = = = End Example = = = = = = = = = = = = =

 

Enjoy. . . .

 

edz
Novice

Re: Http to Https redirect for subdomains working

Hello Roy,

 

I hope you get to see my reply.

 

The information I came across came originated from Apache, thus editing the ssl,conf  file, assuming you have one, should work in other types, or brands, of Linux.

 

Whenever I edit a ".conf" file,  I save a copy of it - before I edit it.

 

Once the ssl.conf is edited you will have to stop and start Apache to see if the change works.

 

You can google: "nixcraft stop / start Apache"  for the different ways of restarting Apache.

 

Best of luck.

Ed.

 

 

 

 

 

VinRao
Novice

Re: Http to Https redirect for subdomains working

Hi, 

 

Are there instructions to apply SSL for subdomains hosted on AWS whilst DNS is with GoDaddy?