I have the following domains:
example1.com
example2.com
example3.com
The domains point to /public_html/
. There are three things I want to do in /public_html/.htaccess
:
Redirect (with all parameters and paths) the domains
example2.com
andexample3.com
to the domainexample1.com
.example1.com
itself should get shown (if not, then redirect) always withhttps
andwww
, means:https://www.example1.com
The custom root path for the domains is
/public_html/
. I want to change this to/public_html/example_path/
.
I have the following in /public_html/.htaccess
:
RewriteCond %{HTTP_HOST} ^example2.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example2.com [NC]
RewriteRule ^(.*)$ https://www.example1.com/$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^example3.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example3.com [NC]
RewriteRule ^(.*)$ https://www.example1.com/$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^example1.com [NC]
RewriteRule ^(.*)$ https://www.example1.com/$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^example1.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example1.com$
RewriteCond %{REQUEST_URI} !example_path/
RewriteRule (.*) /example_path/$1 [L]
This is nearly working as expected. But when opening http://www.example1.com
there is no redirection to https://www.example1.com
. This is only working when removing the last four code lines, that should change the root path.
For all other domains it's working.
Why isn't it woking for http://www.example1.com
? And why is it only working when not changing the root path?