The last couple of hours I have been learning about .htaccess rewrite. I haven't been able to get it right. I have read a lot of posts her on SO, but can't solve my problem. This is my situation:
www.example.com
redirects to
example.example2.com
Now I want to show the original domain in the URL. I have this:
RewriteCond %{HTTP_HOST} ^example\.example2\.com/$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
This doesn't work. I still see the example.example2.com instead of www.example.com
The .htaccess file is located at the top level in the folder for the subdomain.
I should note again that this is new to me and this is what I have been able to come up with from examples I found on the internet. Can someone tell how to get this right?
Thanks a lot
Edit:
I'm trying to install a Drupal multisite configuration. My problem seemed solvable with .htaccess instructions as explained here and here. Because of this I posted it here and not on the Drupal part of SO. The idea of a Drupal multisite configuration is to direct all traffic to the installment and then differentiate according to the request made.
I have no direct control over the redirect from www.example.com to example.example2.com. My hosting company provides a direct redirect or via frame. I can check either one in a form. I don't know what they do. With a direct redirect the URL changes from
www.example.com
toexample.example2.com
. (where the Drupal installation is now) If I choose frame the URL stays the same (of course), but hovering over a link still reveals the example.example2.com identity.I didn't start out with a multisite configuration. I will move
example.exampl2.com
towww.example2.com/sites/www.example.com
as in the instruction for a multisite. In the meanwhile the site is atexample.example2.com
. But that means I have two installments to maintain, which is not preferred. So I started out by trying to haveexample.example2.com
look likewww.example.com
. Then at least visitors would never notice differences.
I now have this
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} ^example\.example2\.nl$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R]
And it results in a loop.