WordPress.org

Support

Support » How-To and Troubleshooting » Setting up custom 404 pages in Dreamhost and WP

Setting up custom 404 pages in Dreamhost and WP

  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Nifty! Thank you. 🙂

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

    Moderator James Huff

    @macmanx

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Setting up custom 404 pages in Dreamhost and WP’ is closed to new replies.
Skip to toolbar