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

I don't understand Introducing Rewrite Rules challenge 3/4.

Next, we need to write the first part of the rewrite rule. This is the pattern that the rewrite rule should match in the web address. (Remember that we are writing a rewrite rule that applies when someone visits http://localhost/flavors/.)

Here's my answer from previous questions below. I have not typed and answer yet.

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

Sorry, treehouse wont let me submit my question "I don't understand Introducing Rewrite Rules challenge 3/4." It keeps telling my to type in atleast a number or letter. Very frustrating. I try editing, but it wont let me do that either.

Please do post a link to the lesson itself.

4 Answers

This is the code you want:

RewriteEngine On
RewriteRule ^flavors/$ /all_flavors.php

Rewrite Rules are not that easy to understand and sometimes they can get really complicated. I suggest you read and do some experiences locally on your server to understand them. Use the tool I specified above to make sure your rules are working before went on crazy try-error testing. The tool allows you to put an url and a rewrite rule and see the final result.

In your case I think the result would be the same but the goal is to change only the flavors part and not the entire url including the localhost.

You can use tools such as: http://htaccess.madewithlove.be to test your htaccess rewrite rules. When asking such a question please put the link to the specific lesson, your code, errors, printscreens and your objective with some examples.

Thanks for all the help Ivo! I'll definitely practice more on the rewrite rules.