简体   繁体   中英

force https for few domains ot of all using htaccess but all domains shared same files

I have setup system so all different domains used the same files and separate content or product based on the store id assigned to each domain.

Now I want to force only 2 domains to use https for all pages using httaccess.

Say, I have 5 domains abc.com, qwe.com, xyz.com, rty.com & uio.com

now I want abc.com & xyz.com to force https, not for other domains.

How I will rewrite rules for this in htaccess file?

Try:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?(abc|xyz)\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R]

in the htaccess in your document root.

This should work for your case:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.com
RewriteCond %{HTTP_HOST} ^xyz\.com
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}.com$1 [R=permanent,L]

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