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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![JONATHAN BOARINI](https://secure.gravatar.com/avatar/82ee5fd22dbfe577d4cb3c65e38e340b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
JONATHAN BOARINI
854 PointsWhy not use a PHP redirect instead of .htaccess rewrites?
I am having trouble configuring my .htaccess to rewrite the url in the shirts folder, and in the mean time, I thought, "Why not just use a PHP redirect?" I created a file named index.php with:
<?php
header('Location: shirts.php'); exit;
and it works perfectly. What is the advantage then of using .htaccess instead?
2 Answers
![Richard Duncan](https://uploads.teamtreehouse.com/production/profile-photos/110689/micro_krdv_avatar.jpg)
Richard Duncan
5,568 PointsI run wordpress as a CMS with a completely custom front end it's a WP template. One advantage I have found of having the redirect in the .htaccess file is that when WP updates it overwrites the PHP header and replaces it with WP code. Bit of a pain when you want to login and start typing.
Another big advantage of this is if you delete a 'page' or file and want a redirect to a new location, you don't need to update every bit of code that references that location, you can change it once in .htaccess and be assured that it will work from now on.
I'm sure there are lots of other reasons.
![JONATHAN BOARINI](https://secure.gravatar.com/avatar/82ee5fd22dbfe577d4cb3c65e38e340b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
JONATHAN BOARINI
854 PointsThat makes sense, thanks for the info! I tried that since I am having issues with my .htaccess, but I will now go back and see how to fix that.