1

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

2
  • as you already tried a rewriterule, could you please post it? perhaps you just missed something in the regex.
    – Christian
    Jan 15, 2010 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, 2010 at 12:37

2 Answers 2

0

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>
2
  • 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, 2010 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, 2010 at 12:18
0

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]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .