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

Category:


Comments and Webmentions

Leave a Reply

Webmentions

If you've written a response on your own site, you can enter that post's URL to reply with a Webmention.

The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.

Learn more about Webmentions.