Welcome to the Treehouse Community
Looking to learn something new?
varis darasirikul10,832 Points
Troubles with Enhancing a Simple PHP Application Challenge task 1 about RewriteRule
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.
and I wrote this but it doesn't work and i dont know why.
RewriteEngine On RewriteRule ^flavors/$ /all_flavors.php RewriteRule ^all_flavors.php$ /flavors/%1/? [R=301]
this is link to a Challenge task (task 1)
Chris Dziewa17,781 Points
It looks like you need to replace the % sign with a $ sign in this last line: /flavors/%1/? .
The percent sign would be used in relation to a RewriteCond rule that involves query strings. Also you shouldn't need the ? mark since that is also meant for that same type of rule and its function is to prevent the query string from being included in the url. The final product should be like this: /flavors/$1/ [R=301]
Hope this helped!