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

RewriteRules for files are not functioning

I am getting this in URL

http://localhost/C:/wamp/www/ecommerce/receipt/

and this on page:

Forbidden

You don't have permission to access /C:/wamp/www/ecommerce/shirts/ on this server.

Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80

My .htaccess file is 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]

first two rules for shirts folder are working fine. The last 3 are being ignored. I get the same behavior if i delete them entirely

Jouni S
Jouni S
4,545 Points

Looks to me you are missing this line: RewriteRule ^(shirts/[0-9]+)$ /$1/ [R=301]

I think you need it for this, which you already have: RewriteRule ^shirts/([0-9]+)/$ /shirts/shirt.php?id=$1