Jump to content

Apache Rewrite URL for product's model number


Recommended Posts

Hi!

I'm coming from a "Loaded Commerce" software solution where, in my old store, all my products have numeric "model names", ie.

 

basket ball   model: 949439

tennis ball    model: 200299

football ball  model: 348994

 

So i had the following rewrite condition in my .htaccess file:

 

RewriteRule ^([0-9]+)$ q.php?modx=$1&%{QUERY_STRING}

 

which called the following file (q.php):

<?php
require('includes/application_top.php');

$modx = $_GET['modx'];

// perform the query
$query = tep_db_query("select products_id from products where products_model = $modx");
$query_result_array = tep_db_fetch_array($query);

if ($query_result_array[products_id]){

/* Redirect browser */
$pxx = $query_result_array[products_id];
header("Location: product_info.php?products_id=$pxx");
/* Make sure that code below does not get executed when we redirect. */
exit;
}
else
{
echo "not found";
}

?>

So whenever anyone types the url: www.mystore.com/modelnumber (aka www.mystore.com/349438) gets straight to that product details page (aka www.mystore.com/that-ball-with-that-model-number.html)

 

 

But im not sure how can i port this to "prestashop environment", that is, an sql query to the db, fill it to the array and "paint" the array into the location: url...

 

 

Any1 kind to help?

Thanks!!

Edited by iAreku (see edit history)
Link to comment
Share on other sites

You can set the model number as a the reference number in Prestashop. Then from the SEO and urls page you can make it use the reference number for the product address. 

 

It is going to be not that great for seo though, I would let prestashop name them with the product name and use this module, http://www.presto-changeo.com/en/prestashop-migration-modules/95-cre-loaded-url-redirect.html  to redirect the pages so you do not lose link juice. 

Link to comment
Share on other sites

  • 3 weeks later...

Dh42,

Thanks for the tip, but im not quite sure if i understood it right.

 

You mean to set the model number to the product id?

Also not sure what redirects have to do here (i mean 30x), its just a rewrite what i need... sort of META HTTP redirect but htaccess rewritten....

Link to comment
Share on other sites

×
×
  • Create New...