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

Introducing Rewrite Rules

The following rewrite rule is in place on my website.

RewriteRule ^flavors/$ flavors/flavors.php

If someone types in this web address, they will see a list of ice cream flavors.

http://localhost/flavors/

What will the web address that appears in their browser be? (Please specify the absolute path.)

Is it not http://localhost/flavors/flavors.php ?

if not.. what is it!?

4 Answers

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

That's the path of the file that will load. But will the address bar have in it? (Remember, the rewrite rule won't redirect to the new address unless you have a [R] flag at the end.)

Does that help?

ahh, gotcha. Makes sense now. THANKS RANDY

What are the steps when we got these kind a problems? Thanks and regards

I cant find it I am too tired of trying all methods. Please anyone help to find out.. Thanks.

what can't you find? the question is already answered

Tell me the steps to find it.. Thanks in advance..

well...if the rewrite rule is: RewriteRule ^flavors/$ /flavors/flavors.php then you are telling the server ,if the user typed www.yourdomain.com/flavors let him see www.yourdomain.com/flavors/flavors.php but keep the address as it is so he will be seeing this address content www.yourdomain.com/flavors/flavors.php , but in his browser the address will be : www.yourdomain.com/flavors P.S: if you are using localhost and your website is inside of a folder in the localhost you must specify that folder name before the rules so it will be like RewriteRule ^flavors/$ /MyWebsiteFolder/flavors/flavors.php dose this help?

AS I understand it...Rewrite rules only affect what the server sees. Think about it only changing what is happening behind the scenes.

To get the change in the browser too, you need to add a [R=301] to the end of the reg ex. Like this :RewriteRule ^flavors/$ flavors/flavors.php [R=301].