Forum Moderators: coopster
Please help. Its been 3 days I have trying to find a solution to this.
Thanks in advance.
[edited by: coopster at 12:13 pm (utc) on April 1, 2009]
[edit reason] no personal urls please TOS [webmasterworld.com] [/edit]
When a user clicks a link on a site, they should not be redirected to some other URL. Link to the URL that you want the user to 'see' and 'use', and use a rewrite (not a redirect) to connect that URL request to the true script location.
There must be some error in your code if the server returns a 404 error for this. Let's see that code.
<?php
require_once 'include/catalog.inc.php';
require_once 'include/url_factory.inc.php';
require_once 'include/url_redirect.inc.php';
require_once 'include/simple_pager.inc.php';
$category_id = $_GET['category_id'];
$categories = Categories::get($category_id);
$category = $categories[0];
$category_name = $category['name'];
$category_first_header = $category['bch2'];
$category_first_header_content = $category['bch2c'];
$category_second_header = $category['bch22'];
$category_second_header_content = $category['bch22c'];
$category_third_header = $category['bch23'];
$category_third_header_content = $category['bch23c'];
$category_metadescription = $category['metadesc'];
$category_metakeywords = $category['metakw'];
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$proper_url = make_category_url($category['name'], $category_id, $page);
fix_category_url($proper_url);
$products = Products::get(0, $category_id);
if (!$products) {
header("HTTP/1.0 404 Not Found");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $category_name; ?> - Same Day Flower Delivery Shop</title>
<link href="/style/sameday-flowerdelivery.css" rel="stylesheet" type="text/css" />
<meta name="Keywords" content="<?php echo $category_metakeywords; ?>" />
<meta name="Description" content="<?php echo $category_metadescription; ?>" />
</head>
<body>
<center>
<div id="TopPanel">
<div id="TopPanelLeft"><a href="http://www.example.com/"><img src="/img/sameday_delivery_flowers_logo.gif" alt="Sameday Flower Delivery" border="0" /></a>
</div>
<div id="TopPanelRight">
<div id="mainLink">
<ul>
<li><a href="http://www.example.com" class="TopLinks">Home</a></li>
</ul>
</div>
</div>
</div>
<div id="TopLinks1">
<div id="TopLinks1Text">
<ul>
<li><a href="<?php echo make_category_url("Mother's Day Flowers", 3); ?>" class="TabLinks">Mother's Day Flowers</a></li>
<li><a href="<?php echo make_category_url("Valentine's Day Flowers", 4); ?>" class="TabLinks">Valentine's Day Flowers</a></li>
<li><a href="<?php echo make_category_url("Congratulations Flowers", 6); ?>" class="TabLinks">Congratulations Flowers</a></li>
<li><a href="<?php echo make_category_url("Gift Baskets", 15); ?>" class="TabLinks">Gift Baskets</a></li>
</ul>
</div>
</div>
<div id="Content">
<div id="ContentLeft">
<?php
echo "<ul>";
foreach ($categories as $category)
{
$url = make_category_url($category['name'], $category['id']);
echo '<li>' .
'<a href="' . $url . '"' . ' class="LeftLinks">' . $category['name'] . '</a>' .
'</li>';
}
echo "</ul>";
?>
</div>
</div>
</center>
<div id="ContentRight">
<h1>Buy <?php echo $category_name ?> -
<a href="/" class="Links">xx</a>
</h1>
p offers the following beautiful <?php echo $category_name; ?> :
<?php
require_once 'include/url_factory.inc.php';
require_once 'include/url_redirect.inc.php';
echo '<table width="779" cellpadding="5" cellspacing="1" class="product">';
$start = ($page - 1) * PRODUCTS_PER_PAGE;
$end = min ($start + PRODUCTS_PER_PAGE, count($products));
for ($i=$start; $i < $end; $i++)
{
$url = make_category_product_url($category_name, $category_id, $products[$i]['name'], $products[$i]['id']);
// TEST TABLE
echo '<tr>' .
'<td class="name">' .
'<a href="'. $url . '"' . '>' . $products[$i]['name'] . '</a>' .
'</td>'. '<td>' . '<a class="zoom" href="#">' . '<img src="' .
$products[$i]['isurl'] .
'" rel="nofollow" alt="Mouse Over for Larger View" width="100" height="100" border="0" />' . '<span>' . '<img src="' .
$products[$i]['isurl'] .
'" rel="nofollow" />' . '</span>' . '</a>' . '</td>' . '<td class="description">' .
$products[$i]['sdesc'] .
'</td>' . '<td nowrap="nowrap" class="country">' .
$products[$i]['country'] .
'</td>' . '<td class="seller">' .
$products[$i]['brand'] .
'</td>' . '<td class="price">' .
$products[$i]['price'] .
'</td>' . '<td>' .
'<a href="' .
$products[$i]['burl'] .
'">' . '<img src="img/buy.gif" alt="Buy Now" width="61" height="14" border="0" />' . '</a>' .
'</td>' . '</tr>';
}
echo "</table>";
// TEST TABLE ENDS
$simple_pager = new SimplePager($products, PRODUCTS_PER_PAGE, 'make_category_url');
echo $simple_pager->display($page, $products, array($category_name, $category_id));
?>
<?php
echo '<h2>' . $category_first_header . '</h2>' . '<p>' . $category_first_header_content . '</p>' . '<br />' . '<h2>' . $category_second_header . '</h2>' . '<p>' . $category_second_header_content . '</p>' . '<br />' . '<h2>' . $category_third_header . '</h2>' . '<p>' . $category_third_header_content . '</p>';
?>
<center>
<div id="Footer">
<div id="FooterContent">
<ul>
<li><a href="http://www.example.com" class="FooterLinks">Home</a></li>
<li><a href="about-us.html" class="FooterLinks">About Us</a></li>
<li><a href="link-exchange.html" class="FooterLinks">Links Exchange</a></li>
<li><a href="other-flower-link.html" class="FooterLinks">Other Flower Links</a></li>
<li><a href="sitemap.html" class="FooterLinks">Sitemap</a></li>
<li class="last"><a href="contact-us.html" class="FooterLinks">Contact</a></li>
</ul>
<br />
© Copyright 2008 - 2009</div>
</div>
</center>
</body>
</html>
[edited by: eelixduppy at 6:13 am (utc) on April 2, 2009]
[edit reason] exemplified [/edit]
if (!$products) {
Add some debugging lines:
print_r($_GET);
var_dump($categories);
Once you can see what's actually being passed to the page, it should make sorting this out much easier. :)
If none of that debugging information shows up, then it is probably an issue with the redirect. In which case, we should still be able to help you here or you can post that code to the Apache forum [webmasterworld.com].
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php¦html)\ HTTP
RewriteRule ^(.*)index\.(php¦html)$ /$1 [R=301,L]
RewriteRule ^Products/.*-C([0-9]+)/Page-([0-9]+)/?$ category.php?category_id=$1&page=$2 [L]
RewriteRule ^Products/.*-C([0-9]+)/?$ category.php?category_id=$1&page=1 [L]
RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$ /product.php?category_id=$1&product_id=$2&%{QUERY_STRING} [L]
RewriteRule ^.*-M([0-9]+)\..*$ /media/$1 [L]
RewriteRule ^robots.txt$ /robots.php
[edited by: eelixduppy at 6:14 am (utc) on April 2, 2009]
[edit reason] exemplified [/edit]