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!

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

crystal oakley
crystal oakley
5,709 Points

Cleaning URLs with Rewrite Rules

The challenge asks to add a rewrite rule to add a trailing slash. I can not figure this out.

RewriteRule ^(flavors/[0-9]+)$ /$1/

RewriteEngine  On   
RewriteRule ^flavors/$ /all_flavors.php
RewriteRule ^(flavors/[0-9]+)$ /$1/ [R=301]

1 Answer

Hi Crystal! I did the RewriteRule section not too long ago and it was really hard for me to wrap my head around. You almost have it. Just remove the /[0-9]+ part and it works. So like this:

RewriteRule ^(flavors)$ /$1/ [R=301] 

I hope this helps!

crystal oakley
crystal oakley
5,709 Points

Worked like a charm. Thanks!

My pleasure! :)