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

Introducing Rewrite Rules - Only shows directory listing

Hi, I'm using XAMPP with a VirtualHost, but i have tried in htdocs on localhost as well. The code in my .htaccess is:

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

Any reason why i'm just getting a directory listing with shirt.php, shirts.php ?

  • Thanks
Matthew Madden
Matthew Madden
5,753 Points

Did you find a solution here? I'm seeing the same thing. I have the site files in a subfolder though, which I have tried in the rule without success. I've made sure that the rewrite module is turned on.

2 Answers

[delete]

Matthew Madden
Matthew Madden
5,753 Points

I didn't have to activate the module, it was already on. I found out by clicking on the wamp icon in the system tray and going to Apache>Apache Modules and then scrolling to find the "rewrite_module" and making sure it was checked.

After messing with the code a bit more, I got this to work (remember I have everything in a subfolder) with the code below.

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

My joy was short lived as now my redirects (next video) aren't working, but I think I'm okay skipping over that part for now.