Forum Moderators: phranque

Message Too Old, No Replies

Query Rewrite Help

redirecting a broken query link

         

c1badmofo

2:49 pm on Oct 27, 2011 (gmt 0)

10+ Year Member



I have several links that look like this:

product_info.php?manufacturers_id=65&products_id=112302
product_info.php?manufacturers_id=645&products_id=101356
product_info.php?manufacturers_id=65&products_id=112301
product_info.php?manufacturers_id=641&products_id=123785

and I need to rewrite replacing
products_info.php with default.php
and remove &products_id=#*$!#*$!

A correct link would be
default.php?manufacturers_id=471

I have tried a rewrite rule as follows
RewriteRule ^default.php?manufacturers_id=(.*)$ product_info.php?manufacturers_id=$2&%{QUERY_STRING}

but no luck

lucy24

7:06 pm on Oct 27, 2011 (gmt 0)

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



Are you positive you remembered to search this Forum for the phrase "query string"? There's a long piece of boilerplate that I paste in about twice a week.

g1smd

7:17 pm on Oct 27, 2011 (gmt 0)

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



and I need to rewrite replacing products_info.php with default.php

Since a rewrite acts on a URL request and modifies the internal pointer to point to a different internal location inside the server, your rewrite should work in exactly the reverse direction to the example stated in your question.

Mod_rewrite cannot make or change URLs. URLs are defined in links. The very first step is to change the links on your pages to point to the right location.