我已经建立了一些主题,并注意到 404 页面一旦上传到我的服务器。永远不会出现。他们总是在我的本地主机设置上做,甚至其他人的主题也有效。
我认为它没有理由不工作,我为漂亮的永久链接启用了 mod_rewrite,但 404 重定向似乎不想工作。
这是一个已知的问题?
是我的 Streamline.net 的糟糕服务器吗?
任何人都可以帮忙吗?
我已经建立了一些主题,并注意到 404 页面一旦上传到我的服务器。永远不会出现。他们总是在我的本地主机设置上做,甚至其他人的主题也有效。
我认为它没有理由不工作,我为漂亮的永久链接启用了 mod_rewrite,但 404 重定向似乎不想工作。
这是一个已知的问题?
是我的 Streamline.net 的糟糕服务器吗?
任何人都可以帮忙吗?
Streamline 遇到同样的问题。我猜这是由于这个主机 1.3 使用的 apache 版本。
您可以尝试在 .htaccess 中设置自己的错误文档,这可能会覆盖您的主机设置,并指向名为“错误”的静态 wordpress 页面或主题中的 404.php
ErrorDocument 401 http://mydomain.com/error/
ErrorDocument 403 http://mydomain.com/error/
ErrorDocument 404 http://mydomain.com/error/
ErrorDocument 500 http://mydomain.com/error/
编辑:您还可以在主题的 404.php 文件中进行重定向(是的,它很难看...)到您的静态错误页面:<?php
Header("Location: http://mydomain.com/error/");
?>
如果这不起作用,我不知道。
如果您的主题模板中已经有一个 404.php 文件,则创建一个。然后按照以下步骤操作。
第一步:在任何编辑器中打开您现有的 404.php 文件,或在主题目录中新建一个。
第二步:在您的 404.php 文件中复制/粘贴下面提供的代码(确保您的 404.php 文件为空白)
//404 Redirect to home in WordPress.
//Sara Domini
//301 Permanently Redirect
//http://2experts.net
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
对我和其他作品来说就像一个魅力:))
It's rather bizarre that this is happening. If WordPress is working with pretty permalinks, then Apache is doing it's job - rewriting any URL that doesn't physically exist to WordPress.
It's then up to WP to decide if the request doesn't match anything, and if so, display a 404.
Perhaps Streamline is screwing this up, by reading the '404 Not Found' header that WP kicks out and fiddling with the output?