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 trialJulian Ptak
30,920 PointsIs 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
Courses Plus Student 15,815 PointsJulian,
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.