Setting up custom 404 pages in Dreamhost and WP (4 posts)

  1. Roar
    Posted 11 years ago #

    FWIW, I thought I would pass this along since it was a little bit hard to follow the Dreamhost instructions, so it had to be tweaked for WP, but was VERY simple.
    Create your custom pages.
    For Dreamhost and WP, they must be named as follows:
    401 /failed_auth.php
    403 /forbidden.php
    404 /missing.php
    500 /internal_error.php
    In the Dreamhost instructions, it says to name them as .html, but it seems to like it better if they are named as PHP.
    Upload those files to your root directory.
    Then, in the Templates Section on WP, add the following to your .htaccess file:
    ErrorDocument 401 /failed_auth.php
    ErrorDocument 403 /forbidden.php
    ErrorDocument 404 /missing.php
    ErrorDocument 500 /internal_error.php

    That should do it.
    My .htaccess file looks like this, the additional code you see with rewrite cond disallows hotlinking. Hotlinking is BAD, very BAD.
    Options -Indexes
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?tuckle.net/.*$ [NC]
    RewriteRule \.(gif|jpg)$ - [F]
    ErrorDocument 401 /failed_auth.php
    ErrorDocument 403 /forbidden.php
    ErrorDocument 404 /missing.php
    ErrorDocument 500 /internal_error.php

    To see my error pages in action?
    http://www.tuckle.net/delete will give you a 403
    http://www.tuckle.net/dogs will give you the 404.

  2. carla
    Posted 11 years ago #

    Nifty! Thank you. :)

  3. asparagus
    Posted 10 years ago #

    My bad, but aren't those the same page?

  4. James Huff
    Support Representative
    Posted 10 years ago #

    As an FYI, I was able to override DreamHost's error page "requirements" (and all of my other hosting provider's error page "requirements") and use my blog's custom 404 page by entering the following into my .htaccess file:

    ErrorDocument 404 /index.php?error=404

    I had though that error document rewrites like this were common knowledge. You don't have to use what your hosting provider would like you to use.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.