Redirect To HTTPS, But Only Apply it to One Domain on GoDaddy

Redirect your Godaddy domain from HTTP to HTTPS, but only apply it to one domain. Or, the second example shows you how to redirect all your GoDaddy domains except one domain. These are necessary if you are hosting multiple “Add-on” domains in your Linux/cPanel hosting account. If you use Godaddy’s rules for “Redirect HTTP to HTTPS automatically,” you will notice that all of your other domains which are hosted in the same hosting account will also redirect to the the main domain.

Example 1: Redirect Only 1 Domain, Not Any Add-on Domains

The following rules for your “.htaccess” file will fix this. Replace yourdomain.com on line 6 with your domain that you do want to redirect to HTTPS. On lines 4 and 5, replace yourdomain\.com while remembering to insert the backslash before the period in your domain name. All other domains, except for this one, will not be redirected.

RewriteEngine On
# Redirect to https, but only apply to one domain, not to add on domains
RewriteCond %{SERVER_PORT} !=443
RewriteCond %{HTTP_HOST} ^yourdomain\.com.* [OR]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com.*
RewriteRule ^ https://yourdomain.com%{REQUEST_URI} [R=301,L]

Important: If you have existing code in your “.htaccess,” add this above where there are already rules with a similar starting prefix.

This works with WordPress, as well. Place these rules above the WordPress rules in your “.htaccess.”

Example 2: Redirect All Domains Except 1 Add-on Domain

The following rules for your “.htaccess” file will redirect all the domains in your cPanel hosting account, except for 1 domain. On lines 4 and 5, replace yourdomain\.com with your domain that you do not want to redirect, while remembering to insert the backslash before the period in your domain name. This domain will not be redirected to HTTPS. All other domains, except for this one, will be redirected from HTTP to HTTPS.

RewriteEngine On
# Redirect to https, but except for one domain...
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^yourdomain\.com.*
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com.*
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Important: If you have existing code in your “.htaccess,” add this above where there are already rules with a similar starting prefix.

This works with WordPress, as well. Place these rules above the WordPress rules in your “.htaccess.”

See more: , , ,

We've 5 Responses

  1. June 22nd, 2015 at 9:06 pm

    Sorry, you can delete the previous comment, I had some other code that was messing with it, now it all works.

    Thanks so much, tried a whole bunch of stuff until I found this, thanks.

    Eben
  2. May 26th, 2017 at 1:16 pm

    You rock – I searched everywhere to get this answer and this was the first thing I could get to work. Thanks so much for sharing!

    Ashley
    • December 18th, 2018 at 10:14 am

      This will do it (it’s simply Example 2 without lines 4 or 5):

      RewriteEngine On
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
      
      Isabel

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]