WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Fake URLs go to index page, not 404.php (16 posts)

  1. onocrotalus
    Member
    Posted 7 years ago #

    Hi all,

    If I enter an address which I know doesn't exist on my site, e.g. http://www.onocrotalus.com/fake, 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
    </IfModule>
    # 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.

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

  3. onocrotalus
    Member
    Posted 7 years ago #

    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?

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

  5. onocrotalus
    Member
    Posted 7 years ago #

    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.

  6. AuntiAlias
    Member
    Posted 7 years ago #

    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.

  7. AshleyxCore
    Member
    Posted 7 years ago #

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

  8. onocrotalus
    Member
    Posted 7 years ago #

    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.

  9. vkaryl
    Member
    Posted 7 years ago #

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

  10. onocrotalus
    Member
    Posted 7 years ago #

    My installation is in root.

  11. vkaryl
    Member
    Posted 7 years ago #

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

  12. talishka
    Member
    Posted 7 years ago #

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

  13. moshu
    Member
    Posted 7 years ago #

    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 :)

  14. talishka
    Member
    Posted 7 years ago #

    Thanks moshu! It works! thanks ;D

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    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.

  16. onocrotalus
    Member
    Posted 7 years ago #

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

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>

    ...called it 404.php, and left it in root. This meant that when I typed in http://www.onocrotalus.com/404.php 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.

Topic Closed

This topic has been closed to new replies.

About this Topic