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 Enhancing a Simple PHP Application Cleaning URLs with Rewrite Rules Adding A Trailing Slash

RewriteRules code challenge, not passing.

Here are the instructions

~In an earlier code challenge, we wrote a rewrite rule so that the web page http://localhost/flavors/ executed the code at all_flavors.php. Unfortunately, this only works if the web address includes the trailing slash. If someone visits http://localhost/flavors, they will see a 404: Page Not Found error. We'll need another rewrite rule to redirect from /flavors to /flavors/. Add a new line to the htaccess file below to accomplish this.

I have this bit of code from the challenge...

RewriteEngine On
RewriteRule ^flavors/$ /all_flavors.php
RewriteRule ^flavors$ /flavors/

The third line is the failing portion.

2 Answers

Hi Weston,

I found this doing a search. Google is your friend.


RewriteEngine  On   
RewriteRule ^flavors/$ /all_flavors.php
RewriteRule ^flavors$ /flavors/ [R=301]

Haha, thank you! I was just coming back to close the discussion. Found the answer. Much appreciated though for your help!