Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Julian Ptak
Julian Ptak
30,920 Points

Is there a Treehouse video or class that deals with .htaccess creation and activation?

I'm working on a project currently that requires that I write an .htaccess file to do something really simple: just a 404 error redirection.

I've got my code in the .htaccess file and the file is on the server. The code (in its entirety) is as follows:

ErrorDocument 404 /404.php

For some reason, the redirection isn't happening. I am completely new to .htaccess file creation so if there is other syntax I'm missing, I wouldn't know.

While I really do need the solution to this problem ASAP, I also want to learn why it works or is broken. So if there is a Treehouse video on this or if anyone has a quick and dirty explanation/solution, I'd really appreciate it.

My initial googling of the problem brought back all sorts of creation tips and tricks and also debugging for Rewrite rules but Stack Overflow doesn't tend to have stuff this simplistic. Any ideas?

In case it makes a difference, the site I am working on is running on a Microsoft server.

1 Answer

Shawn Flanigan
Shawn Flanigan
Courses Plus Student 15,803 Points


Randy touches on .htaccess files in the Enhancing a Simple PHP Application course (under Cleaning URLs with Rewrite Rules), but I don't remember him going into 404s or other Error Documents.

In your post, it looks like you have some spaces in front of your ErrorDocument statement. If so, try deleting any spaces or line breaks before and after your code...see if that helps.