Reputation: 11
I have a server with 3 directories on it in the root and in the root with the 3 directories is a .htaccess
file. Each directory points to a separate domain name.
directoryA
= xamplea.com
directoryB
= xampleb.com
directoryC
= xamplec.com
I want to have 301 redirect code in the .htaccess
file in the root so all files in xamplea.com
redirect to https://xamplea.com
with:
xampleb.com
remaining unaffected.and
xamplec.com
remaining unaffected.I tried:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond xamplea.com ^www\. [NC]
RewriteRule ^ https://xamplea.com%{REQUEST_URI} [R=301,L,NE]
but the above also redirects xampleb.com
and xamplec.com
to https://xamplea.com
when I only want xamplea.com
to be redirected to https://xamplea.com
.
Upvotes: 1
Views: 68
Reputation: 254
Remove the [OR]
in RewriteCond %{HTTPS} off [OR]
since you want both conditions to be true in order to redirect. Also, your second condition is not valid, you probably want to check the domain name.
This would give you:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} xamplea\.com [NC]
RewriteRule (.*) xamplea.com%{REQUEST_URI} [R=301,L,NE]
Upvotes: 1