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

"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