Redirect permanent www.url.com –> www2.url.com

301-redirectapache-2.2mod-rewriteredirect

i have trouble to redirect (via .htaccess) an url like this:

www.url.com/index.php?option=com_content&task=view&id=60&Itemid=22

to

www2.url.com/something.htm

I figured out that the problem is the "old" URL. A "normal" redirect (www.url.com/test.htm –> www2.url.com/something.htm) works great.

I also tried it with rewrite but can´t find a solution that works.

Perhaps someone has and idea how to solve my problem?

Thanks a lot in advance
Lars.

FYI:
Server:
Apache and i have full root access to the server

EDIT Rewrite rule used:

I tried the following with rewrite rule in .htaccess

Test 1:

RewriteCond %{QUERY_STRING} option=com_content&task=view&id=63&Itemid=11 RewriteRule $ www2.url.com [R=301,L] 

Result1: It redirects to the www2 url but not only to www2.url.com. It redirects to www2.url.com/option=com_content&task=view&id=63&Itemid=11

Test 2:

RewriteRule ^option=com_content&task=view&id=63&Itemid=11$ www2.url.com [R=301,L] 

Result2: Nothing happend. Thanks for any further tip 🙂

Best Answer

For the www domain vhost:

<VirtualHost *>
ServerName www.url.com
RewriteEngine on
Rewritecond %{HTTP_HOST} !^www2\.url\.com
RewriteRule (.*) http://www2.url.com/$1 [R=301,L]
</VirtualHost>

And then on www2:

<VirtualHost *>
ServerName www2.url.com
RewriteEngine on
RewriteCond $1 index.php\?option\=com_content\&task\=view\&id\=60\&Itemid\=22
RewriteRule (.*) http://www2.url.com/something.html [R=301,L]
</VirtualHost>