Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialStewart Anderson
10,329 PointsProblem with shirt detail URLs
I seem to be having issues with the clean URLs for the shirt detail pages. All the other site pages seem to be working without any problems, but the clean individual product URLs return 404 errors.
Here's the top portion of my code from the products.php include file:
<code>function get_list_view_html($product_id, $product) {
$output = "";
$output = $output . "<li>";
$output = $output . '<a href="' .BASE_URL . 'shirts/' . $product_id . '">';
$output = $output . '<img src="' . BASE_URL . $product["img"] . '" alt="' . $product["name"] . '">';
$output = $output . "<p>View Details</p>";
$output = $output . "</a>";
$output = $output . "</li>";
return $output;
}</code>
Here's my shirt.php file:
<code><?php
require_once("../includes/config.php");
require_once(ROOT_PATH . "includes/products.php");
if (isset($_GET["id"])) {
$product_id = $_GET["id"];
if (isset($products[$product_id])) {
$product = $products[$product_id];
}
}
if (!isset($product)) {
header("Location:" . BASE_URL . "shirts/");
exit();
}
$section = "shirts";
$pageTitle = $product["name"];
include(ROOT_PATH . "includes/header.php"); ?>
<div class ="section page">
<div class="wrapper">
<div class="breadcrumb"><a href="<?php echo BASE_URL; ?>shirts/">Shirts</a> > <?php echo $product["name"]; ?></div>
<div class="shirt-picture">
<span>
<img src="<?php echo BASE_URL . $product["img"]; ?>" alt="<?php echo $pageTitle; ?>"
</span>
</div>
<div class="shirt-details">
<h1><span class="price">$<?php echo $product["price"]; ?></span><?php echo $product["name"]; ?></h1>
<p class="note-designer">* All shirts are designed by Mike the Frog. *</p>
</div>
</div>
</div>
<?php include(ROOT_PATH . "includes/footer.php"); ?></code>
Thanks in advance for any help...hopefully I didn't just fail to spot a typo.
1 Answer
Alan Johnson
7,625 PointsHi Stewart! Are you around the part of the course where you're learning about url rewriting as well? What's your htaccess file looking like?