Question: I have the following rewrite rule in order to control my different international domains to redirect to the main domain.

```
RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(ru|co.in|in|de|com.br|co.uk|ca|com|com/)
RewriteRule ^.*$ http://www.[percent]1.[percent]2[percent]{REQUEST_URI} [R=301,L]

```

This has been working for the past few years.

Today, when I try to create a domain alias that contains one of the letters above, for example: tvonline.domain.com, it redirects to tvon.in. Basically happens with any alias that contains the letters in, ru, de, ca. 

Is there something I can do about this?

Thanks!

Answer: 
There are several issues with the pattern matching, but the problem is likely in the line matching your international TLDs. Here is the issue on each line:

1. The `.` is a wildcard so you are going to get a negative match on `www.domain.com` but also `wwwxxx.domain.com` with the `*` to match 0 or more of any character.
2. The `%{HTTP_HOST}` should never be empty.
3. The `.` is a wildcard for any character and you aren't exclusively matching the end of the `%{HTTP_HOST}` with `$`. Use the a `?` to make the first pattern ungreedy. You don't need to match on `co.in` because it will be matched by `in`.
4. I'm *guessing* that the `[percent]` in your example is really `%`, which is what it should be.

Try the following in place of what you have now:

```
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.*?)\.(ru|in|de|com\.br|co\.uk|ca|com|com)$
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]

```

Testing using <http://htaccess.madewithlove.be/>:

Rewrite:

```
Input URL: http://tvonline.domain.com/test.html

1. RewriteCond %{HTTP_HOST} !^www\. 
     This condition was met
2. RewriteCond %{HTTP_HOST} ^(.*?)\.(ru|in|de|com\.br|co\.uk|ca|com|com)$   
     This condition was met
3. RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]    
     This rule was met, the new url is http://www.tvonline.domain.com/test.html
     The tests are stopped, using a different host will cause a redirect

Output URL: http://www.tvonline.domain.com/test.html

```

No Rewrite:

```
Input URL: http://www.tvonline.domain.com/test.html

1. RewriteCond %{HTTP_HOST} !^www\. 
     This condition was not met
2. RewriteCond %{HTTP_HOST} ^(.*?)\.(ru|in|de|com\.br|co\.uk|ca|com|com)$   
     This condition was met
3. RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]    
     This rule was not met because one of the conditions was not met

```
Thanks! This led me at the right direction in order to solve this issue. This is what I used to get it to work.

```
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]*?).(ru|in|de|com\.br|co\.uk|ca|com|com)$
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]

```