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 trialOscar Gomez
2,277 PointsRewrite rule for Get variable on shirts not working
I have added the following code to my .htaccess file but it doesn't seem to be working and I get a '404 Not Found' error. localhost/shirts/ works however once I go to localhost/shirts/108...I get the error mentioned. Here is my .htaccess code
RewriteEngine On RewriteRule ^shirts/$ /shirts/shirts.php RewriteRule ^shirts([0-9]+)/$ /shirts/shirt.php?id=$1
2 Answers
Luis Vazquez
6,370 PointsHi Oscar,
You're forgetting a "/" after "shirts in the second Rewrite Rule.
Copy and paste this code:
RewriteEngine On
RewriteRule ^shirts/$ /shirts/shirts.php
RewriteRule ^shirts/([0-9]+)/$ /shirts/shirt.php?id=$1
Let me know if that works.
-Luis
Oscar Gomez
2,277 PointsWow, I could not figure it out for my life!
Thanks Luis, that was exactly it!
Luis Vazquez
6,370 PointsNo problem Oscar!