• I’m having trouble with 404 redirection and a new theme on WordPress 2.7.

    I want to set 404 behavior in my .htaccess file.

    Just for testing purposes, I have the .htaccess file redirect all 403 and 404s to some other famous site, like:

    ErrorDocument 403 http://google.com/
    ErrorDocument 404 http://cnn.com/

    The 403 redirection works perfectly. The 404 redirection does not.

    What happens is that for any 404 page, WordPress draws an index.php for that page with a wp_title value of “Page not found”. (The theme does not have a 404.php and it’s not using the 404.php from the default theme.) Oh, and none of the Adsense Manager blocks show up on that page either.

    How do I get the server to use .htaccess for a 404 instead of WordPress?

    I thought that Apache looks at the .htaccess before WordPress is even invoked, so this whole thing is soooo confusing to me. Why can’t I specify what to do for 404 pages?

    (All I want it to for a 404 is to just load the home page of my site, not show a custom page.)

    Thanks for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jentorme

    (@jentorme)

    I should also mention that I’m using “/%postname%/” as my permalink structure because the site design calls for that. I’ve had no other problems with it at all and aside from the inability to get the 404 in .htaccess, the site’s running beautifully.

    Please if anyone is out there, please help!

    Thread Starter jentorme

    (@jentorme)

    I’ve been playing wtih my permalinks and I changed it to one of the defaults and still have this problem, so it’s not related to the use of postname as the sole delineator in permalinks.

    To sum up: I can’t redirect 404’s with my .htaccess file. 403’s redirect fine through that but not 404s, which instead load the index.php file. Why? How to change this? Anyone out there?

    Thread Starter jentorme

    (@jentorme)

    Ok, this is definitely a Mod_Rewrite issue.

    When using the “default” WordPress URL format (ugly), the ErrorDocument directive in the .htaccess file is read.

    But changing the permalinks to anything at all, any of the giving formats, will make the ErrorDocument line useless.

    Why?

    Thread Starter jentorme

    (@jentorme)

    Ok boys, I know how to kludge around this. You just make your 404.php a PHP redirect to wherever you want your 404 to go.

    But I still don’t get why .htaccess can redirect a 403 and not a 404. It’s probably because once you have these rewrite rules in place, there really *is* no 404 … it’s just passed right on to WordPress.

    If that’s the case, I think the codex really needs a big bold section on this. Because I’ve found so many people on here with the same problem, always unanswered. You guys listening? Please update the docs. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Getting .htaccess to override WordPress defaults’ is closed to new replies.