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
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.
RewriteEngine On RewriteRule ^flavors/$ /all_flavors.php
what should i do after this?
RewriteRule ^flavors$ /flavors/ [R=301]
The key to this rewrite is the "$" which matches the end of the string. Remember though, this matches a position, not a character.
Outside of this challenge, I would do this
RewriteRule ^flavors/?$ /flavors/ [R=301]
The ? means optional in regular expression speak.
This is just for anyone who views this for help on the challenge. I know that this one can be a little difficult..
RewriteEngine On RewriteRule ^flavors/$ /all_flavors.php RewriteRule ^(flavors)$ /$1/ [R=301]