Error Document Handling with .htaccess

Today I saw that I was getting a bunch of requests for http://cagrimmett.com/blog, which was the landing page for my 2008-2014 blog that I took down last year. That page does not exist now and “blog” is now just a directory on my site generated by Jekyll’s paginator.

I wanted to take those requests and forward them to the landing page of my new blog. The /blog/ requests were all 403 errors, and any direct link to an old post is a 404 error. So I added these two lines to my main .htaccess file to handle the request:

ErrorDocument 403 / ErrorDocument 404 /404.html

This means:

“Take any 403 error and show the user the site’s front page (/)”

“Take any 404 error and show the user the 404 page”