简体   繁体   中英

htaccess: Redirect All domains (https and http) to new domain

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

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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM