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 trial

PHP Enhancing a Simple PHP Application Cleaning URLs with Rewrite Rules Introducing Rewrite Rules

.htcaccess redirecting individual shirts detail page to shirts.php

shirts.php is displaying properly, when I hover on an individual item it displays the proper id. When I click on the item it simply reloads shirts.php.

I would post some code but I don't know where to look.

1 Answer

The code would help a lot, try use codepen to post the code.

Here is the .htcaccess

RewriteEngine On
RewriteRule ^shirts/$ /shirts/shirts.php

This is shirts.php

<?php include("inc/products.php"); 

if (isset($_GET["id"])) {
    $product_id = $_GET["id"];
    if (isset($products[$product_id])) {
        $product = $products[$product_id];
    }
}
// Redirect when there isn't a valid entry.
if (!isset($product)) {
    header("Location: shirts.php");
    exit ();
}

$section = "shirts";
$pageTitle = $product["name"];
include("inc/header.php"); ?>


    <div class="section page">

        <div class="wrapper">

            <div class="breadcrumb"><a href="shirts.php">Shirts</a> &gt; <?php echo $product["name"]; ?></div>

            <div class="shirt-picture">
                <span>
                    <img src="<?php echo $product["img"]; ?>" alt="<?php echo $product["name"]; ?>">
                </span> 
            </div>

            <div class="shirt-details">

                <h1><span class="price">$<?php echo $product["price"]; ?></span> <?php echo $product["name"]; ?></h1>


                <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
                    <input type="hidden" name="cmd" value="_s-xclick">
                    <input type="hidden" name="hosted_button_id" value="<?php echo $product["paypal"]; ?>">
                    <input type="hidden" name="item_name" value="<?php echo $product["name"]; ?>">
                    <table>
                    <tr>
                        <th>
                            <input type="hidden" name="on0" value="Small">
                            <label for="os0">Small</label>
                        </th>
                        <td>
                            <select name="os0" id="os0">
                                <?php foreach($product["sizes"] as $size) { ?>      
                                <option value="<?php echo $size; ?>"><?php echo $size; ?> </option>
                                <?php } ?>

                            </select> 
                        </td>
                    </tr>
                    </table>
                    <input type="submit" value="Add to Cart" name="submit">
                </form>

                <p class="note-designer">* All shirts are designed by Mike the Frog.</p>

            </div>

        </div>

    </div>

<?php include("inc/footer.php"); ?>

I'm just guessing that this is where the problem is.