网站管理员工具中的php seo 404错误

时间:2016-05-21 16:46:06

标签: php seo search-engine google-webmaster-tools

我有一个包含1000页的PHP网站... 我每天都会删除已经被GOOGLE索引的10页页面....

当访问者访问其中一个页面时,我会检查是否删除了... 如果删除我将用户重定向到搜索页面以开始搜索类似内容... 我正在使用此代码:

if($deleted = true){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /products-search.php");
    exit(); 
}

在GOOGLE网站管理员工具中我为此类网页获得了大量软404错误的问题。 消息说:目标URL不存在,但您的服务器未返回404(找不到文件)错误。了解更多

我不希望用户收到404错误....我需要他去搜索页面...

如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

除非您希望稍后重新放回该页面,否则您仍应返回404。在这种情况下,重定向对于SEO来说是个坏主意。

您可以做的是在标题中返回404,但无论如何都会显示搜索页面:

RewriteEngine on
RewriteCond %{REQUEST_URI} my-custom-page.php

# the line above to choose only my-custom-page.php and if you remove it
# the code will remove all php pages extensions

RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [L,R]