WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cannot verify with google, 200 Ok "error" (5 posts)

  1. shanemcgough1130
    Member
    Posted 7 years ago #

    Ive searched google and these forums, and found a few answers to this problem, none work for me.

    WordPress returns a 200 Ok repsonse instead of a 404 not found response if you put in a wrong url. Google doesn't allow this.

    ive found two fixes, neither worked. One said to put

    <?php if (!have_posts()) { header('HTTP/1.0 404 Not Found'); } ?>

    as the very first line in the header.

    The other said to put:

    <?php header("HTTP/1.1 404 Not Found"); ?>

    Into the 404.php file.

    Then a third solution i found stated that the problem is created if you install wordpress into a subdirectory, and to move your files to the root dir. Did that, still no help.

    (side note: the 404.php file is different in size on the server than it is on my home pc, which i thought was because i added the new line of text, but when i overwrite, it still shows as a slightly smaller size on the server. i can download it again, overwrite the local version with the server version... the new line is there, but still the data size is smaller on the server.)

    Can anyone help?

    I also tried adding the meta tag to the header file. When i view the header file, the meta tag is there, but when i view source on my page it isnt, and i cant verify my site with google, they say the meta tag isnt there.

    I know html, but not php. :/

    site is http://www.dontfearthetruth.com

    Thanks in advance to anyone who can help.

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

    WordPress will return a 404 correctly if the correct conditions exist. There's nothing special that needs to be done.

    However, it is possible to set it up incorrectly without realizing it, and accidentally break the 404 pages.

    Looking at your site, I see that you're not using "pretty" permalinks. However, I also see that fake URLs resolve to your main page. This indicates an incorrect .htaccess to me.

    So, in that case, try renaming your .htaccess file to something else. Also, post the contents of your .htaccess file here, so we can figure out what it will be doing.

  3. shanemcgough1130
    Member
    Posted 7 years ago #

    .htaccess:

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

    # END WordPress

    I didnt edit this at all, is this file specific to the theme i am using? The fake URLS resolving to the main page seems to be the reason it doesnt work, i thought this was a feature of wordpress... this isnt the standard way that wordpress works?

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

    i thought this was a feature of wordpress... this isnt the standard way that wordpress works?
    No, that's not normal.

    What's going on is that you are using the default permalinks, but have an .htaccess which will really only work for the non-default ones. It redirects everything to the index.php (as it should) but URLs aren't parsed for information because you're using default permalinks. So everything resolves to the index page unless it has the right GET parameters in the URL.

    Try switching to anything other than "Default" on the Options->Permalinks page. That should fix your problem and make the 404 page work correctly.

    Also, remove those special header lines you added, you should not need them.

  5. shanemcgough1130
    Member
    Posted 7 years ago #

    ok ill try it, but when i tried changing the permalinks one time (thought that having a hierarchy that was logical to users would be nice) it screwed up the site. ill try again though. thanks.

    EDIT: Works fine now, thanks a TON for the help, ill change this to resolved.

    thanks again. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags