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!
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 trialShay Ofer
14,151 Points.htaccess and 404 error...
Hi guys, i'll try to keep short and punctual and if anyone can help that would be great!
I've finished the "Enhancing a Simple PHP Application" already but since the section about ReWrite rules my shirts and shirts page gives me a 404 error which i can't for the life of me solve.
I've tried altering the xampp config files as stated at on some forums, tried various alterations to my .htaccess code and when all of these failed, I downloaded the project files and used Randy's code assuming it cannot fail, but it did.
The project along with the .htaccess files are under a shirts4mike_local subfolder inside my htdocs folder and my .htaccess code looks loke this:
'''RewriteEngine On RewriteRule ^shirts/$ /shirts/shirts.php RewriteRule ^shirts/([0-9]+)/$ /shirts/shirt.php?id=$1
RewriteRule ^receipt.php$ /receipt/ [R=301] RewriteRule ^contact.php$ /contact/ [R=301] RewriteRule ^shirts.php$ /shirts/ [R=301] RewriteRule ^(shirts/[0-9]+)$ /$1/ [R=301]
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ RewriteRule ^shirt.php$ /shirts/%1/? [R=301]'''
The search, cart and contact tabs work just fine, tough anything to do with shirts and shirt gets an error 404. I've already googled my ass of and tried everything i could think of but to no avail, if anyone could help I would very much appreciate that!
Cheers, Shay
1 Answer
Shay Ofer
14,151 PointsSorry, i'll refactor the code in my message:
''' RewriteEngine On RewriteRule ^shirts/$ /shirts/shirts.php RewriteRule ^shirts/([0-9]+)/$ /shirts/shirt.php?id=$1
RewriteRule ^receipt.php$ /receipt/ [R=301] RewriteRule ^contact.php$ /contact/ [R=301] RewriteRule ^shirts.php$ /shirts/ [R=301] RewriteRule ^(shirts/[0-9]+)$ /$1/ [R=301]
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ RewriteRule ^shirt.php$ /shirts/%1/? [R=301] '''