Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

"Shirts" page returning error 404

I finished the "Enhancing a simple PHP application" project and wanted to add it to my portfolio page. Everything works except for the link to the shirts page, i get error 404. i even downloaded the final project files, and it is still the same story. Please help!

6 Answers

resolved! i had extra "/" in my rewrite rules

what is the file path to your shirts page?

I have everything in a sub folder on my server, the URL is: http://crimsonmoonwebdesign.com/shirts_for_mike/shirts/ the code for the link in my header file:

<li class="shirts <?php if ($section == "shirts") { echo "on"; } ?>"><a href="<?php echo BASE_URL; ?>shirts/">Shirts</a></li>

i found this post at stack overflow that explains how to include base url for all your pages.

http://stackoverflow.com/questions/15481629/how-do-i-set-base-url-for-all-pages-of-my-website

Hope this helps.

iain saunders
iain saunders
9,531 Points

<p>Jay are you sure you updated your .htaccess file? Currently the link you provided doesn't work unless you add shirts.php after the slash, which suggests to me that your RewriteRule needs to be corrected. I had a similar problem with subfolders :)</p> <p>Make sure you have something similar to the following :<br> RewriteEngine On<br> RewriteRule ^shirts_for_mike/shirts/$ /shirts_for_mike/shirts/shirts.php</p>

edit: added markdown for better visibility (hope it works)

Iain: here is my .htaccess code after i added the line you suggested.

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

RewriteRule ^receipt.php$ /receipt/ [R=301]
RewriteRule ^contact.php$ /contact/ [R=301]
RewriteRule ^shirts_for_mike/shirts/$ /shirts_for_mike/shirts/shirts.php [R=301]
RewriteRule ^(shirts/[0-9]+)$ /$1/ [R=301]

RewriteCond %{QUERY_STRING} ^id=([0-9]+)$

I think you you;re sending me down the right path though