Product pages redirect

Doing some editing today and some of my product codes have changed, problem is this code is used in the url and has been indexed by google so how would I redirect one product page to the new one

h ttp://mydomain/proddetail.php?prod=2031

to

h ttp://mydomain/proddetail.php?prod=1728
 

david64

Free Member
Mar 17, 2009
1,041
458
dddddddd
If you are using Apache, which is most likely, you will probably have a module on your server called mod_rewrite which can re-direct URLs.

You may have a file in the root directory called .htaccess, if not you will need to create one and add the line:

RewriteEngine on

To do the re-write add the line:

RewriteRule ^proddetail.php?prod=2031$ proddetail.php?prod=1728
 
Upvote 0
No I cant...

Just spoken to my developer and because my pages are dynamic I cannot redirect.
shrug.gif


Just tried adding this to my htaccess file and I still go to the deleted product

It a pain in the butt because items change fairly frequently...and currently if they have been indexed by google the only real way I can do it is to mark the product as not for sale.....this then keeps the product there and looks like this Rayware The Boss Dog Bowl. - Ceramic Dog Bowls - Dog Bowls - Dogs (they cant actually add it to their basket

If I delete a product they get this page Pet Supplies from Pet Shop 2u - We care about your pets which is just naff.

So the first option is better but over time I will have hundreds of "phone for price and availability" products littering my site.
shrug.gif


My developer has suggested a javascript redirection - I havent a clue about that so what are peoples opinions?
 
Upvote 0

david64

Free Member
Mar 17, 2009
1,041
458
dddddddd
The standard solution is to use mod_rewrite, which is the thing I gave you. There is a possibility the rule I gave you didn't work. Since I can't check my self I can't say.

I checked and you are running on an Apache server, which means that mod_rewrite is probably installed. Your web developer should be about to do some sort of redirect like the one I gave you above.

JavaScript re-direct just sounds like a botch to me.

Just spoken to my developer and because my pages are dynamic I cannot redirect.

That doesn't make sense. Dynamic pages are easier to redirect. There are more options to do so on dynamic pages.
 
Upvote 0
Its not necessarily just the ids....some of my urls dont eevn have ids.

Products change / get discontinued / get replaced quite frequently so looking for a solution for all circumstances so that I dont have to have loads of "phone for price and availability" products :|
 
Upvote 0

MGSteve

Free Member
Apr 29, 2009
49
4
Walsall, UK
David - depends what settings he can use within the .htaccess file, no all options are enabled, especially on a shared host. But I agreee, most Apache servers do have it installed and enabled.

Javascript does sound like a botch, to be honest, as does any other means of keeping track of the old ID.

The only way to fix this is to stop the product IDs changing. In the shop system we developed we keep track of the product ID in the import file and use that to update the corresponding record in the shop system. Simply wiping the shop database and repopulating it is a very, very, lazy way of doing it and leads to problems such as yours.

Also, its not a good idea to use Dynamic URLs, they don't tend to be liked by Search Engines, besides which, with a properly developed system you can stuff the product name etc.. into the URL, helping SEO.


e.g. a sample URL of a site we've done would be

h ttp://www.ptp-ltd.co.uk/shop/20_35/lotus/lotus_elise_s2_(toyota)/induction_system/s2_eliseexige_-_itg_maxogen_induction_system.htm

Much more readable and stuffed with keywords!
Tell your developer to get his finger out of his backside and fix the problem instead of proposing botch fixes!
 
Last edited:
Upvote 0

MichaelG

Free Member
Sep 1, 2005
461
16
Berkshire
Looking at http://petshop2u.co.uk - try adding something like this to the top of proddetail.php

<?php

if ($_GET['prod']) {
$row = mysql_fetch_array(mysql_query("SELECT productname FROM producttable WHERE productname = '".str_replace("_"," ",$_GET['prod'])."'"));
if (!$row['productname']) {
header("Status: 200");
header("location:http://www.yourdomain.com/search.php?stext=".str_replace("_"," ",$_GET['prod']),TRUE,301);
exit;
}
}

?>

The above will check the database to see if the product exist. If the product is not found, than the request is sent to your search page.

But listen to MGSteve.
 
Upvote 0

Latest Articles