Hi,
I am having some problems with mod rewrite on the followg page
http://www.babyuniverse.com.au/shopping/nursery-and-furniture.php/
The code is below
<?php
require("includes/common.php");
require("html/header.php");
require("html/searchform.php");
?>
<h1>Welcome to Clothing and Footwear</h1>
<br>
<font size="2">Narrow your Search:</font>
<table width="100%" border="0">
<tr>
<td width="25%"><a href="http://www.babyuniverse.com.au/shopping/search.php?q=boot&log=1">Booties</a></td>
<td width="25%"><a href="http://www.babyuniverse.com.au/shopping/search.php?q=shoes&log=1">Shoes</a></td>
<td width="25%"><a href="http://www.babyuniverse.com.au/shopping/search.php?q=t-shirt&log=1">T-Shirts</a></td>
<td width="25%"><a href="http://www.babyuniverse.com.au/shopping/search.php?q=Mattress&log=1">Mattresses</a></td>
<td width="25%"><a href="http://www.babyuniverse.com.au/shopping/search.php?q=Mattress&log=1">Tall Boy</a></td>
</tr>
<tr>
<td><a href="http://www.babyuniverse.com.au/shopping/search.php?q=Blanket&log=1">Blankets</a></td>
<td><a href="http://www.babyuniverse.com.au/shopping/search.php?q=Chest&log=1">Chest of Drawers</a></td>
<td><a href="http://www.babyuniverse.com.au/shopping/search.php?q=desk&log=1">Desk</a></td>
<td><a href="http://www.babyuniverse.com.au/shopping/search.php?q=Sofa&log=1">Sofa</a></td>
<td><a href="http://www.babyuniverse.com.au/shopping/search.php?q=wardrobe&log=1">Wardrobes</a></td>
</tr>
<tr>
<td><a href="http://www.babyuniverse.com.au/shopping/search.php?q=Rocker&log=1">Rockers</a></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br>
<?php
print javascript_focus("search.q");
// BEGIN MOD
$category = "Clothing and Footwear";
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE category='".$category."' GROUP BY name LIMIT 10";
$searchresults["numRows"] = database_querySelect($sql,$rows);
$searchresults["products"] = $rows;
if ($searchresults["numRows"])
{
foreach($searchresults["products"] as $k => $product)
{
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
}
else
{
$searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
}
}
require("html/searchresults.php");
}
// END MOD
require("html/footer.php");
?>
Basically I have create a php file for the category and added some subcategory searches on this page.
The subcategory searches work fine, however the 10 random results of category clothing-and-footwear are generating an incorrect URL and including the php filename as follows
http://www.babyuniverse.com.au/shopping/nursery-and-furniture.php/product/-NEW-Tashi-Desk.html
Any ideas on how to correct this in .htaccess or if you can provide a better way of adding these subsearches.
Regards
richard
Hello Richard,
It's probably best to use $config_baseHREF rather than trying to construct a relative URL. Where you currently have:
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
}
...change this to:
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = $config_baseHREF . "product/".$searchresults["products"][$k]["productHREF"];
}
Hope this helps,
Cheers,
David.