One WordPress site on one of my servers is giving an incorrect HTTP response code when a page can not be found. On the end-user side, the user sees a custom 404 page. But on the web-server side Apache is giving a 200 or 300 response (not sure which one) instead of a 404 response. Other WP sites on the same server give the correct response code.

This error was discovered by McAffee SiteAdvisor:

It appears that the Web site freewomensblogs.com (or www.freewomensblogs.com) is returning an HTTP 2xx or 3xx status response code in the header of 404 pages.

We cannot verify a Web site that is configured this way because it allows anyone to verify themselves as the owner of your site. Please update your Web site server configuration to return 404 status codes in the headers for pages that do not exist. Once your site is configured this way then you can return and request a file name verification.

Please help.

This is the .htaccess file which is currently in use on the site:

RewriteEngine On
RewriteBase /

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ /$1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>

RewriteCond %{HTTP_HOST} ^freewomensblogs.info$ [OR]
RewriteCond %{HTTP_HOST} ^www.freewomensblogs.info$
RewriteRule ^(.*)$ "http\:\/\/freewomensblogs\.com\/" [R=301,L]


RewriteCond %{HTTP_REFERER} !^http://(.+\.)?freewomensblogs\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

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


# END WordPress

It is server-side problem. Better ask on PHP forum. Move this thread to PHP forum.

It is server-side problem. Better ask on PHP forum. Move this thread to PHP forum.

Actually, WordPress handles HTTP response codes on its own. Also, there is a redirect in the .htaccess code I posted which might not need to be there, but I'm not sure. So, it's not a server-side problem or a PHP problem. It's either a WordPress problem or an .htaccess problem.

Regardless, this has nothing to do with HTML or CSS.

It's a problem with both. Try renaming .htaccess to .htaccess.old and retry the McAfee verification. If that works then follow the verification process at the end. And rename your .htaccess.old file back to .htaccess

Regards
Arkinder

Regardless, this has nothing to do with HTML or CSS.

Agreed, but there is no section for CMS or blogging.

No worry about that. Post this thread to PHP. Your problem is inclusive in PHP even if there is no wordpress or htaccess forum. Indeed, they are involving with PHP.

Moving to PHP.

Agreed, but there is no section for CMS or blogging.

Understandable, did you try what I suggested?

Regards
Arkinder

Understandable, did you try what I suggested?

Yes. I even narrowed it down and discovered that pages which should give a 404 response are giving a 301 response, probably because of the .htaccess redirects. I just have to figure out how to tweak it.

Oops, I understood your problem but lost it somewhere along the way. ^_^ Try adding this to your .htaccess file.

ErrorDocument 404 /error404.php

If you already have this, or it doesn't solve the problem. Then your issue is with McAffee.

Regards
Arkinder

The problem was this line in .htaccess causing 404 to pages to show up as 301:

RewriteCond %{HTTP_HOST} ^freewomensblogs.info$ [OR]
RewriteCond %{HTTP_HOST} ^www.freewomensblogs.info$
RewriteRule ^(.*)$ "http\:\/\/freewomensblogs\.com\/" [R=301,L]

Awesome, so you just changed this line from 301 to 404?

RewriteRule ^(.*)$ "http\:\/\/freewomensblogs\.com\/" [R=301,L]

The reason I said that it would be an issue with McAffee is there was a glitch in 2010 with this same issue.

Regards
Arkinder

If you have update to 3.2.1 probably it is server incompatibility related to JSON, I was facing this a week ago, but now it have disappear. Also try to check your website from another computer. There is a malware which is making this problem, if you can not replicate this on the other machine, probably your PC is infected.

Awesome, so you just changed this line from 301 to 404?

I actually removed those 3 lines entirely. freewomensblogs.info is no longer being used, so the redirect was no longer necessary.

If you have update to 3.2.1 probably it is server incompatibility related to JSON, I was facing this a week ago, but now it have disappear. Also try to check your website from another computer. There is a malware which is making this problem, if you can not replicate this on the other machine, probably your PC is infected.

Upgrade what to 3.2.1? JSON has no effect on .htaccess or redirects. This has been checked from different sources and showed the same results. Malware on a client computer does not cause web servers to give incorrect HTTP response codes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.