Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Enhancing a Simple PHP Application Cleaning URLs with Rewrite Rules Get Variables and Rewrite Rules

Derek Dawes
Derek Dawes
4,944 Points

Rewrite on .htaccess not changing get id to a "/"

Hello once again,

I added the code per the instructions and can't seem to get the get id to leave the url. Here's my .htaccess code.

RewriteEngine On
RewriteBase /shirts4mike_local/

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

Here's what outputs to the browser when I select a shirt in the /shirts/ page

http://localhost/shirts4mike_local/shirts/shirt.php?id=103

the id didnt change to shirts/shirt/103 like the video is teaching. Thank you Im using WAMP

I'm having the same problem as you Derek. The rewrite works for the Apache redirect to shirts.php but my URL after the change to shirt.php is still : http://localhost/shirts/shirts.php?id=101.

Here is my .htaccess doc

RewriteEngine On

RewriteRule ^shirts/$ /shirts/shirts.php

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

I'm on a Macbook so I'm using MAMP for my local host.