Forum Moderators: phranque

Message Too Old, No Replies

what's wrong with this redirection rule?

         

olaf

8:51 am on Jan 12, 2006 (gmt 0)

10+ Year Member



Hello,

I wan't to redirect (outdated) entries in google to the new content page.

the old link is like this:
[domain.com...]

and my current (not working) rule is this:
rewriteEngine on
RewriteRule ^/languages/traxx.php?lang=([a-z]{2})&sec_lang=([A-Z]{2}) /products.php?lang=$1-$2 [L,R=permanent]

What's I have similar working rule (I think)

Anyone an idea?

Regards Olaf

jd01

11:21 am on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, to 'see' information in a query string, you must use a QUERY_STRING condition.

RewriteEngine on
RewriteCond %{QUERY_STRING} lang=([a-z]{2})&sec_lang=([A-Z]{2})
RewriteRule ^/languages/traxx.php$ /products.php?lang=%1-%2 [L,R=permanent]

Hope this helps.

There is some more information in the library and charter that might be helpful also.

Justin

olaf

11:56 am on Jan 12, 2006 (gmt 0)

10+ Year Member



Hello,

I think that this is not what I want. I have more then one page with this query string. I tried it but with the same result than with my own rule.

What I don't understand is that this kind of rule has worked for a diff. website.

Olaf

jdMorgan

12:39 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is your code in .htaccess or httpd.conf?

Jim

olaf

1:16 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



.htaccess

I use this (working) rules in the same file:

Options +FollowSymLinks
rewriteEngine on

RewriteCond %{SERVER_NAME} ^www\.example\.de$ [NC]
RewriteRule ^$ main.php?lang=de-DE [L]

RewriteCond %{SERVER_NAME} ^www\.example\.nl$ [NC]
RewriteRule ^$ main.php?lang=nl-NL [L]

rewriteCond %{SERVER_NAME} ^(www\.)?example\.com$
rewriteCond %{REQUEST_URI} ^/home.php [OR]
rewriteCond %{REQUEST_URI} ^/bergtoys.php [OR]
rewriteCond %{REQUEST_URI} ^/games.php [OR]
rewriteCond %{REQUEST_URI} ^/faq.php [OR]
rewriteCond %{REQUEST_URI} ^/kleurplaten.php [OR]
rewriteCond %{REQUEST_URI} ^/producten.php [OR]
rewriteCond %{REQUEST_URI} ^/spreekbeurt.php [OR]
rewriteCond %{REQUEST_URI} ^/zeurtips.php [OR]
rewriteCond %{REQUEST_URI} ^/workouts.php
RewriteRule .* [kids.bergtoys.com%{REQUEST_URI}...] [L,R=permanent]

The first two are suggested from you.

[edited by: jdMorgan at 2:27 am (utc) on Jan. 13, 2006]
[edit reason] examplified per TOS. [/edit]

jdMorgan

2:27 am on Jan 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In .htaccess, URLs matched by RewriteRule patterns are localized to the current directory. That is, the path to the current directory, including the leading slash is stripped. This will require a modification of jd01's code to:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})&sec_lang=([A-Z]{2})
RewriteRule [b]^la[/b]nguages/traxx.php$ /products.php?lang=%1-%2 [L,R=permanent]

Which appears to be exactly what you wanted, except with the correct mod_rewrite and .htaccess syntax.

Jim

olaf

7:15 am on Jan 13, 2006 (gmt 0)

10+ Year Member



Thanks Justin and Jim,

It works, I will remember the thing with the leading slash. It looks to me know that a a rule with a condition works much better then a rule with some regex only.

Olaf