为什么我的网站对存在且可访问的页面给出 404 错误?

发布于 2024-11-05 02:04:41 字数 471 浏览 6 评论 0原文

我的问题是在我网站上的某些页面上,例如 http://www .piranha-internet.co.uk/web/website-design.php 我在 Google 网站管理员工具中收到 404 错误。但是我可以正常访问这些页面,它们都有指向内部的链接,但还没有来自外部的链接。

  • 我已经在此页面上进行了标头检查,并且也收到了 404 错误。
  • 我在我的服务器上创建了空白文件,它们看起来很好,给了我 200 代码,但如果我复制并重命名有问题的 404 文件,我会得到相同的 404 错误。
  • 我的网站上大约有 40 个页面,其中一半给出 200 代码,一半给出 404。它们都使用相同的结构和内容。包括相同的内容,但所有内容都不同。

为什么会发生这种情况?

My problem is that on certain pages on my website such as http://www.piranha-internet.co.uk/web/website-design.php I am been served with a 404 error in Google Webmaster Tools. However I can access the pages normally, they all have links pointing to them internally, non yet from external.

  • I have done header checks on this page and get served a 404 as well.
  • I have created blank files on my server and they seem fine giving me a 200 code but if I duplicate and rename the 404 files in question I get the same 404 errors.
  • I have roughly 40 pages on my site, half of which give 200 code and half 404. They all use the same structure & same includes but the content is different on all of them.

Why is this happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷你仙 2024-11-12 02:04:41

当我尝试在 HTML 页面之前将我的 WordPress 标头包含在代码顶部时,我遇到了同样的问题,

<?php
    include('blog/wp-blog-header.php');
?>

但 Google 看到了 404 并且不会索引页面。

通过将 PHP include 移到 HTML 正文中解决了该问题。

奇怪的问题...

I had the same problem when I tried to include my wordpress header at the top of the code before the HTML

<?php
    include('blog/wp-blog-header.php');
?>

The pages worked but Google saw a 404 and wouldn't index the pages.

Solved the problem by moving the PHP include inside the body of the HTML.

Weird problem...

Dan

缪败 2024-11-12 02:04:41

当我访问 http://www.piranha-internet.co 时,它会出现。使用 Fiddler 访问 uk/web/website-design.php 时,我得到了随页面内容一起返回的 404 HTTP 状态代码。您的服务器或您的代码实际上正在发送 404 HTTP 状态代码。

您是否可以显示相关页面的一些 .php 源代码,例如 website-design.php 和标头包含文件?

编辑:

你能尝试一种系统化的方法吗:
从空白页开始,返回
200 HTTP 代码。添加 HTML 行 /
PHP 来自那些页面之一
逐行返回 404,并保留
每次更改后进行测试,直到您
查找导致 404 错误的更改
而不是 200。看看是否可以
追踪到特定的一行
代码,特定函数调用,
include 等,并发布结果。

It appears when I visit http://www.piranha-internet.co.uk/web/website-design.php using Fiddler, I get a 404 HTTP status code returned along with the page content. Somewhere your server, or your code is actually sending a 404 HTTP status code.

Is there a possibility you could show some of your .php source code for the relevant pages, such as website-design.php and the header include files?

Edit:

Could you try a systematic approach:
Start with a blank page, that returns
a 200 HTTP code. Add lines of HTML /
PHP from one of those pages that
returns a 404, line by line, and keep
testing after each change until you
find what change sent it to a 404
instead of a 200. See if you can
trace it down to a specific line of
code, a specific function call,
include etc., and post the result.

彩扇题诗 2024-11-12 02:04:41

您在 GWT 中看到的是实际的 HTTP 响应代码。 404 在你的情况下意味着“未找到”。

根据定义,这会将请求标记为“未找到”,这就是 GWT 向您报告的内容。

在任何 PHP 脚本中,除了输出之外,您还可以设置响应代码。我对 /web/website-design.php 的代码没有深入的了解,所以很难判断出了什么问题或者是否有问题。

您可以在代码中查找 header() 函数 的使用。该函数可以设置响应代码。

What you see in GWT is the actual HTTP response code. 404 in your case an it means "Not Found".

By definition this marks the request as "Not found" and that's what GWT reports to you.

Within any PHP script you can set the response code in addition to the output. I have no insight into the code of /web/website-design.php so it's hard to tell what's wrong or if it's wrong at all.

You could look for the use of the header() function within your code. That function can set the response code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文