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 trialjack hamilton
5,609 PointsGet Variables and Rewrite Rules
Much like this question
https://teamtreehouse.com/forum/get-variables-and-rewrite-rules
I can not get /shirts/108 to work
I've managed to get /shirts working by removing the / at the start like so
RewriteRule ^shirts/$ shirts/shirts.php
But that second one doesn't seem to work.
RewriteRule ^shirts/([0-9]+)/$ shirts/shirt.php?id=$1
I'm on windows 7 / Chrome/ Sublime / Xampp
2 Answers
thomascawthorn
22,986 PointsTake a really good look at this line
RewriteRule ^shirts/([0-9]+)/$ shirts/shirt.php?id=$1
See the trailing slash? You're checking for this pattern:
shirts / ([0-9]+) /
so try adding a slash at the end of your url.
/shirts/108/
Christopher Bijalba
12,446 Pointscan you explain why the beginning slash doesn't work for me? I still have my files in a subfolder localhost/shirts4mike2/shirts/
RewriteRule ^shirts/$ shirts/shirts.php
RewriteRule ^shirts/([0-9]+)/$ shirts/shirt.php?id=$1
is what i could get working, but that might be a problem since its relative?
thomascawthorn
22,986 PointsAt this point, have you started on creating root relative constants?
Christopher Bijalba
12,446 PointsSorry - I did not see the notification, and started a thread!
https://teamtreehouse.com/forum/redirects-not-functioning-with-subfolder has all of my details, thanks!
jack hamilton
5,609 Pointsjack hamilton
5,609 PointsHuh I kind of assumed it would have accepted it without the trailing / Thanks! Is there a way of doing either with or without that trailing /?
thomascawthorn
22,986 Pointsthomascawthorn
22,986 PointsI believe you're going to cover that in a few videos time :)