0

My current domain is a free https.

I add new domains as parked domains Alias (in DirectAdmin).

So for the new domain to use https, I need to disable https for the old domains.

Now I want to transfer all the old domains to the new domain with https.

I think the solution is that https should be disabled for all domains except the new domain, then the address will be transferred to the new domain

2 Answers2

2

You can force https like so:

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

That should go to your .htaccess to your root folder

source: https://www.siteground.com/kb/how-to-force-ssl-with-htaccess/

Daniel Kemeny
  • 640
  • 1
  • 5
  • 11
  • I do not want a forced https. I want https to be disabled for all domains except the new domain. Also, all domains will be transferred to the new domain –  Apr 20 '19 at 09:09
0

You can use this :

RewriteEngine on

RewriteCond %{HTTP_HOST} !^(www\.)?newdomain\.com$ [NC]
RewriteRule (.*) https://www.newdomain.com/$1 [L,R=301]

This will redirect all parked domains (pointing to your document root) to your new domain url .

The RewriteCondition above makes sure you don't redirect newdoman to itself otherwise the rule would cause a redirect loop error.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • This code does not pass `https://oldDomain.com` to the new domain. Because the error appears in the browser: **Your connection is not private.** I think the solution is that https should be disabled for all domains except the new domain, then the address will be transferred to the new domain. –  Apr 20 '19 at 13:01
  • @Mohammad you need to install valid ssl certs for your domains in order to redirect them. – Amit Verma Apr 20 '19 at 13:45
  • There are codes for transmitting https to http. I just want the code to change so that it does not include the new domain –  Apr 20 '19 at 13:52
  • @mohammad if ssl cert doesn't exist for the domain your are trying to redirect from `https` to `http` then there is nothing htaccess redirect can do in that case you would need to buy a valid cert and install on the domain. You are getting `connection not private` error from the ssl module as your domain doesn't have ssl installed . – Amit Verma Apr 20 '19 at 14:39