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

Arbee Jacob Pagalilauan
Arbee Jacob Pagalilauan
7,483 Points

RewriteCond part not working even after browser refresh, stopping-starting apache, clearing cache and restarting desktop

My .htaccess looks like the following:

RewriteEngine On RewriteRule ^shirts/$ /EnhanceSimplePHPApp/shirts/shirts.php

RewriteRule ^shirts/([0-9]+)/$ /EnhanceSimplePHPApp/shirts/shirt.php?id=$1

RewriteRule ^receipt.php$ /EnhanceSimplePHPApp/receipt/ [R=301] RewriteRule ^contact.php$ /EnhanceSimplePHPApp/contact/ [R=301] RewriteRule ^shirts.php$ /EnhanceSimplePHPApp/shirts/ [R=301]

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

The last 2 lines seems to be not working in my local instance (using XAMPP) when accessing the following: http://localhost/EnhanceSimplePHPApp/shirts/shirt.php?id=104

It does load the page but does not redirect. I've refreshed my browser, stopped-started apache, cleared my browser's cache (IE, FF, Chrome) and restarted my desktop but the redirect in the rewritecond part is still not working.

Please advise on what to do in this case. Thanks in advance.