Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 :-)

share|improve this question
    
as you already tried a rewriterule, could you please post it? perhaps you just missed something in the regex. –  Christian Jan 15 '10 at 11:01
    
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 :-) –  Lars Jan 15 '10 at 12:37

2 Answers 2

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>
share|improve this answer
    
Hi Mark, thanks for your quick reply! But that doesn´t work for me :-( I tested this and modified the vhost config file in the sections for www and www2 domain - sorry - no success. Any other idea? –  Lars Jan 15 '10 at 12:04
    
Is could be the escaping in the second rewritecond conf there doesn't work properly. Could you run curl -Iv "url.com/…; and let me know what the output of that is and what it should be? –  Mark L Jan 15 '10 at 12:18
up vote 0 down vote accepted

Figured out how to solve my problem - thanks to all for any tip on my way to this solution.

I added the following entry to my .htaccess file in my httpdocs root folder of my www.url.com domain:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?option=com_content&task=view&id=12&Itemid=11\ HTTP/
RewriteRule ^index\.php$ http://www2.url.com/?p=77 [R=301,L]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.