Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic URL Redirection

Status
Not open for further replies.

eiffel76

Programmer
Nov 7, 2006
7
US
I have several pages that are dynamically generated, but lead to the same page. I.e.:

product_info.php?manufacturers_id=11&products_id=727
product_info.php?cPath=199_28_195&products_id=727
product_info.php?products_id=727

As far as I can tell, Search Engines will see this as duplicate content. I'd like all pages to go to: product_info.php?products_id=727

After much searching, it appears that "RewriteCond" and "RewriteRule" in an .htaccess can take "product_info.php" and turn it into "product_info.php?products_id=727", but as far as I can tell, they don't do what I'd like to do. - In general, they don't seem to do much with dynamic urls. (And people who try end up finding out the script does nothing noticeable. - For the interested parties: http://answers.google.com/answers/threadview?id=587953 - no conclusion to this thread yet, and I tried the examples with no success)

It appears "RedirectMatch" does not work with dynamic URLs. (The default Cpanel method)

If apache can't, can a PHP (or other language) script do this?

Too much searching for this guy...
Thanks in advance!
 
I got help. Here's the working code:
Code:
RewriteEngine on

RewriteCond %{QUERY_STRING} ^.+products_id=([0-9]+)$ [NC]
RewriteRule ^product_info\.php$ domain_here/product_info.php?products_id=%1 [R=301,L]

For higher education on mod_rewrite, I found the following pages helpful:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top