Forum Moderators: phranque

Message Too Old, No Replies

Consolidating Dynamic Pages. How to 301

         

TonyMc

4:37 am on Dec 26, 2005 (gmt 0)

10+ Year Member



Sort of a remedial 301 question using mod rewrite. I am consolidating a number of subcategories for my products into a broader category. These are all dynamic pages. How would I rewrite the dynamic page to another dynamic page? My URL's look like...

domain.com/products.php?cat=5

I just need to send requests for cat=5 to cat=23.

I'm using a rewrite rule already to go from non-www to www but I'm a little lost with this dynamic page. I'd appreciate any help. Thanks

jdMorgan

5:48 am on Dec 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



While we don't normally write code on demand here (see forum charter [webmasterworld.com]), I'm giving in to the holiday spirit, and also "giving credit" for a good/uniquely-worded title on this thread. ;)

RewriteCond %{QUERY_STRING} ^cat=5$
RewriteRule ^products\.php$ http://www.example.com/products.php?cat=23 [R=301,L]

That's a specifc solution for the problem exactly as stated, and I assume you're adding this code to existing and working rules in .htaccess. If not, then the code will need to be modified or supplemented with other directives.

Be sure to place this code before your existing domain redirect, in order to avoid multiple redirects on these requests.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

TonyMc

6:52 am on Dec 26, 2005 (gmt 0)

10+ Year Member



Thanks very much. Merry Christmas!