I have a website with 2 different domains, for example:
www.example.com www.example.net
Now i want, that every user coming from example.com should be redirected to www.example.de
Ill tried:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^.*$ http://example.de/$0 [L,QSA,R=301]
But now still all users from example.net get redirected to example.de
How can i solve that, that only users from example.com gets redirected (also with all subfolders).
Thanks!
Try this - you want to match example.com (remove the !), and it's clearer to capture the incoming url into $1.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ http://example.de/$1 [L,QSA,R=301]
Also, while debugging, change the R=301
to R
, so your browser doesn't "stick" with an old rule. When it works, change it back to R=301
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With