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 Adding Search: Model Introducing the strpos Function

Kyle Damken
Kyle Damken
10,633 Points

Getting a not found error for the shirts page when I put the project in a folder inside the root directory.

So I downloaded the project files from this lesson, and when I load them directly into my localhost root directory they work fine. However, if I move them into a subfolder in that directory, lets call it th, and modify the config file to reflect this, everything works except the link to the shirts page at the top. So the contact, and search links work fine, but the shirts one does not. Instead it gives me a file not found error.

I've included a link to some screenshots I took of what my files look like at the moment. - https://imgur.com/a/7bINm

I suspect it may have something to do with my rewrite rules but I can't figure it out. Any help would be greatly appreciated.

2 Answers

geoffrey
geoffrey
28,736 Points

Hi Kyle, I've just checked quickly, and yes It seems It's something wrong with your rewrite rules. However, I'm not very good at it. I suggest you to download the projects files of shirts 4 Mike, this way you'll be able to compare and correct wrong rules.

Kyle Damken
Kyle Damken
10,633 Points

Hey thanks for responding. I actually downloading the project files originally when I had posted this, and those are the ones that aren't working.

Rewrite like this and it works:

RewriteEngine On RewriteRule ^shirts/$ /shirts4mike/shirts/shirts.php RewriteRule ^shirts/([0-9]+)/$ /shirts4mike/shirts/shirt.php?id=$1 RewriteRule ^receipt.php$ /shirts4mike/receipt/ [R=301] RewriteRule ^contact.php$ /shirts4mike/contact/ [R=301] RewriteRule ^shirts.php$ /shirts4mike/shirts/ [R=301] RewriteRule ^(shirts/[0-9]+)$ /$1/ [R=301]

RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ RewriteRule ^shirt.php$ /shirts/%1/? [R=301]

In your case replace "shirts4mike" with "th".