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

Clean URLs rewrite query string

Hello. I'm trying to redirect pages using mod rewrite, but doing so with text instead of numbers.

For instance, I need:

http://www.mysite.com/people.php?id=2 to be http://www.mysite.com/people/john-smith/

I know how to do this for existing pages, but would like an automated way to handle new pages in the future. The slug 'john-smith' is stored in the database for the particular page.

Can you help me out?

2 Answers

Hi Micah, this guide on mod rewrite should get you in the right direction.

Thanks, this looks like what I need. I will test it out, thanks for the quick reply.