从 WordPress 中的 404 页面重定向用户:(Redirect users from 404 page in WordPress:)好吧,我确定您在 WordPress 网站中遇到 404 页面错误,(404-page error in your WordPress website)并且希望将用户从WordPress中的 404 页面重定向到您的主页或任何自定义页面。那么本指南肯定会对您有所帮助。
我知道处理 404 重定向是多么累人。因此,为了帮助您解决这个问题,我们提供了这个很好的指南,它将尝试解决您与 404 页面错误相关的所有问题。
如何从 WordPress 中的 404 页面重定向用户:
您可以通过两种方式从Wordpress中的 404 页面重定向用户,让我们看看它们。
方法 1:手动创建(MANUALLY CREATE A)404 页
在这种方法中,您可以手动创建 404 重定向页面,每当用户遇到 404 页面时,他们将被重定向到您的博客/网站的主页(Homepage)。所以这对每个人来说基本上是一个双赢的局面。
让我们看看如何创建 404 重定向页面:
1.从您的网站 URL 示例登录到您的Wordpress管理员帐户:www.abc.com/wp-admin/ 应该是默认格式。
2.现在从外观转到编辑器。
3.这将打开您的主题编辑器,您可以在其中创建 404 重定向页面文件。
4.现在可能应该已经有一个名为 404.php 的文件,在这种情况下您不必创建一个新文件。
5.但如果您没有该文件,那么您创建一个您必须登录到您的Cpanel的文件,然后转到文件(File)管理器,然后找到您的 public_html 文件夹。
6.现在从那里转到 wp-content 然后主题,现在浏览您当前的主题文件夹并创建一个名为 404.php 的新文件,然后转到下一步。
7.现在,当您在编辑器中或创建了一个新文件时,只需将以下代码放入您的文件中,并确保您的文件不包含除此代码之外的任何其他内容:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
?>
方法2:安装(INSTALL)404重定向插件(REDIRECT PLUGIN)
这是您可以将用户从WordPress中的 404 页面重定向到您的博客/网站上任何您想要的任何地方的最简单方法。有大量的插件可以帮助你解决这个问题,但我只会谈论最好的:
1.重定向(Redirection)
这个插件可以做任何与重定向相关的事情。它简单而强大,而且完全免费,拥有高达 600,000+ 的Active安装,它是迄今为止最好的插件之一。
如果您要从托管帐户迁移或正在更改WordPress目录,此插件非常有用。
特点包括:
- 帖子URL(URL)更改时自动添加 301 重定向
- 为WordPress(WordPress)帖子或任何其他文件手动添加 301、302 和 307 重定向
- 完整的正则表达式支持
- (Apache .htaccess)不需要Apache .htaccess – 完全在WordPress中工作(WordPress)
- 重定向(Redirect)index.php、index.html 和 index.htm 访问
- 重定向统计信息告诉您重定向发生了多少次、上次发生的时间、尝试执行此操作的人员以及他们在何处找到您的 URL
- 完全本地化
更重要的是,这个插件在大多数语言中都可用,所以现在你现在为什么它被称为最好的插件之一。去这里(Go here)下载插件,或者你也可以从Wordpress中安装它。
2.全部404重定向到首页(All 404 Redirect to Homepage)
如果您对上面的重定向插件不满意,因为上面的插件会对您的数据库造成影响,那么请不要担心这个 404重定向(Redirect)插件特别适合您。这是一个非常简单的插件,没有像上面的插件那样的高级功能,但它完全可以完成它的工作。
随着 90,000+ 的主动安装,它是仅次于Redirection的第二好的插件。此插件可让您将 404 页面重定向到主页或任何其他自定义页面。
这就是您将要了解的关于如何(How)在Wordpress中从 404 页面重定向用户的全部内容。如果您对这篇文章仍有疑问,请随时在评论中提问。
您还可以在您的社交网络上分享此帖子,以帮助您的家人和朋友在重定向问题上苦苦挣扎。
Redirect users from 404 page in WordPress
Redirect users from 404 page in WordPress: Well, I am sure you are facing a 404-page error in your WordPress website and want to redirect users from 404 page in WordPress to your homepage or any customize page. Then this guide is definitely going to help you.
I know how tiring it can be to deal with 404 redirects. So to help you deal with this issue we have this nice guide which will try to solve all your problems related to 404-page errors.
How to redirect users from 404 page in WordPress:
There can be two ways through which you can redirect users from 404 page in Wordpress, let’s see both of them.
METHOD 1: MANUALLY CREATE A 404-PAGE
In this method, you can manually create your 404 redirect page and whenever a user is encountered with 404 page they will be redirected to the Homepage of your blog/website. So it’s basically a win-win situation for everybody.
Let’s see how to create a 404 redirect page:
1.Login to your Wordpress admin account from your website URL example: www.abc.com/wp-admin/ should be the default format.
2.Now from Appearance go to Editor.
3.This will open your theme editor where you to create the 404 redirect page file.
4.Now it’s possible that there should already be a file by name 404.php in which case you don’t have to create a new one.
5.But if you don’t have the file then you to create one for which you have to login int your Cpanel, then go to File manager, then locate your public_html folder.
6.Now from there go to wp-content then themes, now browse your current theme folder and create a new file with name 404.php and go to the next step.
7.Now when you are inside the editor or you have created a new file just put the below code in your file and make sure you file doesn’t contain anything else other than this code:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
?>
METHOD 2: INSTALL A 404 REDIRECT PLUGIN
This is the easiest way you could redirect users from a 404 page in WordPress to anywhere you want on your blog/website. There are ample of plugins presents to help you with this but I am going to only talk about the best ones:
This one plugin can do anything that is related to redirection. Its simple yet powerful and that too totally free with a whopping 600,000+ Active install its one of the best plugins to be present till date.
This plugin is very useful if you are migrating from your hosting account or your are changing WordPress directories.
Features include:
- Automatically add a 301 redirection when a post’s URL changes
- Manually add 301, 302, and 307 redirections for a WordPress post, or for any other file
- Full regular expression support
- Apache .htaccess is not required – works entirely inside WordPress
- Redirect index.php, index.html, and index.htm access
- Redirection statistics telling you how many times a redirection has occurred, when it last happened, who tried to do it, and where they found your URL
- Fully localized
And what’s more this plugin is available in most of the language, so now you now why it’s called one of the best plugins. Go here to download the plugin or you can also install it from within the Wordpress.
If you are not happy with the above redirection plugin because the above plugin is taking its toll on your database then don’t worry this 404 Redirect plugin is especially for you. It’s a very simple and doesn’t have an advanced feature like the above plugin but it totally does its job.
With an active install of 90,000+ its the second best plugin after Redirection. This plugin lets you redirects your 404 page to home page or any other customize page.
That’s all you are going to learn about How to Redirect users from 404 page in Wordpress. If you still have a question regarding this post feel free to ask them in comments.
You can also share this post on your social network in order to help your family and friends struggling with redirects problems.