Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

redirect question: could be a problem


3:21 am on Jan 5, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:July 8, 2004
votes: 0

Friends -

Here's my issue. I have an installation of a popular shopping cart. That cart generates the products in the format of /product.php pages w/ the specific product ID attached. (i.e. www.mysite.com/product.php?ID234)

I have rewritten the cart extensively because the client needed a very highly customized shopping process. Now, the customer is directed to a new page, /product1.php which servers up the proper options for checking out.

However, Google is still indexing the cart and all of the products with the /product.php extention.

I am wondering if its possible to write a redirect that, if clicked from an external referrer, redirects any product.php page to the exact same page, exept as product1.php.


If so, is it is possible to leave the INTERNAL workings of the cart unaffected? That is, some pages DO start with product.php and should be left along. It's just the ones coming from google search that I need to redirect.

Is this possibe?


3:48 am on Jan 5, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

It's a rather big mistake to redirect anything just because the script changed. Why give up all of the nicely-indexed pages already in search engines?

Best practice? Never, ever change a URL unless a lawsuit forces you to do so, and never return a 404-Not Found for any URL that has ever been valid on your site. Either serve a genuine replacement page, or return a 410-Gone.

Now, to answer your question, yes it is possible, and not very difficult. You will need to use mod_rewrite, use a RewriteCond directive to check the %{HTTP_REFERER} variable for search engine referrals, simply pass the query string through, which is the default behaviour of mod_rewrite, and Redirect from product.php to product1.php

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].