Support » Fixing WordPress » Fake URLs go to index page, not 404.php

  • Resolved onocrotalus


    Hi all,

    If I enter an address which I know doesn’t exist on my site, e.g., I am taken to index.php, not 404.php. My .htaccess file is as follows:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php
    # END WordPress`

    Mod_rewrite seems to be working because I get a 500 error if I replace the rewrite rule with garbage. If I remove the RewriteCond and RewriteRule lines entirely, then head to a fake URL, I get the server’s 404 page. I just can’t find any way to make my own 404.php appear.
    I’ve tried the fix suggested in this thread, with no success.

    I don’t know if it’s relevant, but I have this problem with trying to get permalinks working too.

    I am using WP 2.0.4, my host is Lycos, plugins are Askimet, Custom Query String, and Sitemaps. WP is installed at the root.

    Any advice would be very kind.

Viewing 15 replies - 1 through 15 (of 15 total)
  • It’s because WordPress isn’t detecting that URL as a 404 (it’s not sending a 404 header). Why? No clue, but I can only think that it’s your server.

    Thanks for replying. I’ll send the query to my host as well..but surely squillions of people use Lycos and their 404 procedure works fine?

    No, WordPress, not your server, is not sending a 404. But why WP is not is beyond me, but my guess was something funky on your server as it works fine here.

    And to be frank, I wouldn’t be surprised if a host like Lycos had a crazy server config…

    Thanks for your help. Any advice about where I might suggest they start looking? I haven’t had a response from Lycos yet. Just anything extra info that might improve my chances of getting them to respond/do something about it/etc., really.

    I’ve a similar problem, where I’m setting up on a new server with a newly-upgraded WP 2.0.4. I’ve got a pretty custom 404 page, but I can’t get it to show.

    In my htaccess file, I’ve got this line to direct to my custom 404…..

    htaccess line is
    ErrorDocument 404 /errors/404.html

    ….but I don’t get any 404-style results. Just the home page of the site. So I’d like to know whatever the diagnosis upthread “wordpress doesn’t declare it/serve it/respond to it as a 404” means and what I can do about it.



    Is there a way to get around this? I keep getting my homepage for 404s also, I want to use my custom error page like I was doing before…



    Using this verbose htaccess plugin half-solved the problem; I don’t get my WP 404 page, but I do get the server’s own basic 404.



    Are you guys installing wp in root or in its own folder?



    My installation is in root.



    I *think* I remember something about that causing custom 404 pages to get “lost” a while back. You might try a deep google search for various keywords; I couldn’t find it in a local search just now – but since I don’t remember much about the whole thing that’s no surprise, I probably didn’t give it the “right” keystring. Believe me, it’s NOT simply “404” (yeah, it’s probably in there but about 100 pages deep or so!) – but you might try things on google like “custom 404 page missing wordpress root install” and suchlike….



    no news about this issue? i’m havin it too.



    If you place the 404.php file in your active theme folder – it will be used. I know, it’s crazy, but I just tested it 🙂



    Thanks moshu! It works! thanks ;D

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    A lot of people seem to be confused about how 404’s and WordPress work…

    WordPress intercepts *all* requests for files and directories that don’t exist, under it’s own directory structure. Then it parses the request to see if it’s a page, a category, an individual post, etc. If it can’t find a match, it’ll use the 404.php file in the theme.

    So the more normal 404 methods like ErrorDocument and such will not work, because WordPress intercepts *all* pages and returns *something* valid for them. You will never get a 404 page except through WordPress’s templating mechanism.

    After a LOT of headscratching, I can now get my proper WP 404 page to show when it should. I made a copy of the root index.php file…

    /* Short and sweet */
    define('WP_USE_THEMES', true);

    …called it 404.php, and left it in root. This meant that when I typed in the WP 404 page actually appeared – before, it just loaded the index page.

    Then I added a line at the top of my .htaccess file:

    ErrorDocument 404 /404.php

    Trying /index.php?error=404 as the ErrorDocument location didn’t work; a non-existent address loaded the index page. I don’t quite understand why this solution works – it mostly got to it by elimination and luck. If anyone with more knowledge can see a potential problem with this method – or understands what’s going on here and why it was necessary – I’d be interested to know.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Fake URLs go to index page, not 404.php’ is closed to new replies.