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 Enhancing a Simple PHP Application Cleaning URLs with Rewrite Rules Adding a Trailing Slash

What is the difference between $ and % in a backreference?

I am confused. In one case in the rewrite rules, it looks like Andy uses /%1/ as a backreference but in the other one (and in the code challenge) he uses /$1/.

What is the difference between $ and % in a backreference?

1 Answer

Both are backreferences, but for different sources. The dollar sign ($1-9) refers to RewriteRule. And the percentage sign (%1-9) refers to RewriteCond. It's just mod_rewrite's way of removing confusion about what the backreference is meant to actually reference.

Thank you!