Forum Moderators: phranque

Message Too Old, No Replies

redirect dynamic url to dynamic url, how to?

         

Fingers68

9:55 pm on Mar 6, 2010 (gmt 0)



old url

/shop_products.php?page=variable1&subcat_id=&cat_id=variable2

new url

/shop_products.php?page=variable1&id=variable2

subcat_id is a redundant variable which I want to remove, however google as indexed a great number of them and this will cause duplicate content problems if I do not redirect.

I have seen this

RewriteCond %{QUERY_STRING} ^auto(moduleŚcom)=downloads((&[^&]+)*)&?$
RewriteRule ^board/index\.php$ http://example.com/board/index.php?app=downloads%2 [R=301,L]

here [webmasterworld.com...]

But I am struggling to see how this might fit into my situation? And would I be better off with redirect as google has indexed these pages?

g1smd

10:27 pm on Mar 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, you'll need that redirect to fix the old links that are already known to search engines.

Capture both wanted variables in separate backreferences using a RewriteCond. Re-use them as %1 and %2 in the target URL of the redirect.


You also need to think whether now is the time to dump parameters completely and move to URLs like:
/products/id-variable2/page-variable1
instead. There are many advantages.

Fingers68

8:34 am on Mar 8, 2010 (gmt 0)



Can you be a little more specific please? I am not to upto speed with RewriteCond?

Fingers68

9:04 am on Mar 12, 2010 (gmt 0)



Still looking for solution to this if theres any help out there thanks?

jdMorgan

9:50 pm on Mar 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The fastest path to a solution that will be exactly correct for your needs, and that you can understand, modify, and maintain without requiring dozens more posts in this thread is here [httpd.apache.org]. The resources cited in our Forum Charter -- and indeed, the Charter itself, may add some clarity to this thread.

The general form will be:

RewriteCond %{QUERY_STRING} ^page=([^&]+)&subcat_id=[^&]*&cat_id=([^&]+)$
RewriteRule ^shop_products\.php$ http://www.example.com/shop_products.php?page=%1&id=%2 [R=301,L]

But there are any number of "ifs, ands, or buts" that may affect whether that's what you really want.

Jim