0

We are now using OpenCart and domain aliasses in DirectAdmin. We now have some rules in our htaccess for redirecting non www to www and non https to https. But this rule is for all domains. We only want to use it for example-1.com

How can we do this? Htaccess we have tried all failled to do this.

This is the current htaccess we have

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

We only want this for example-1 and example 2 also. But now it always redirects to example-1

2 Answers2

1

I understand you only try to redirect example-1 and example-2 and not other domains. You can use that:

RewriteCond %{HTTP_HOST} (?:^|\.)(example-1\.com|example-2\.com)$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R=301]
Croises
  • 18,570
  • 4
  • 30
  • 47
0

Try:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [L,R=301] 
Jon Lin
  • 142,182
  • 29
  • 220
  • 220