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

Rewrite Rules with Query Strings - problem with URL

Here is my htaccess file, and last 2 rows is problematic.

RewriteEngine on
RewriteRule ^shirts/$ /root/shirts4mike/shirts/shirts.php/
RewriteRule ^shirts/([0-9]+)/$ shirts/shirt.php?id=$1
RewriteRule ^contact.php$ /root/shirts4mike/contact/ [R=301]
RewriteRule ^reciept.php$ /root/shirts4mike/reciept/ [R=301]
RewriteRule ^shirts.php$ /root/shirts4mike/shirts/ [R=301]

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


When i enter url adress

http://localhost/root/shirts4mike/shirt.php?id=101

It redirects me to this url

http://localhost/root/shirts4mike/shirts/**101?id=101** Why?

1 Answer

The problem is the f***** apache cache.

Everyone who have some strange behaviour with rewrite, just clear browser cache!