wordpress 重定向_在WordPress中创建301重定向的初学者指南(逐步)

wordpress 重定向

Are you trying to create a redirect in WordPress? Not sure what a redirect is and why it is important? Don’t worry, we have got you covered in this beginner’s guide to WordPress redirects, we will cover what a redirect is, how to create a redirect in WordPress, why do you need, and when you should use redirects.

您是否要在WordPress中创建重定向? 不确定重定向是什么,为什么重定向很重要? 不用担心,我们已经在WordPress重定向新手指南中介绍了您,我们将介绍什么是重定向,如何在WordPress中创建重定向,为什么需要以及何时使用重定向。

Ready? Let’s get started.

准备? 让我们开始吧。

Website Redirects
WordPress中的重定向是什么? (What is a Redirect in WordPress?)

A redirect is a way for your website to send a quick message to your reader’s browser and tell them that the page they want to visit has been moved, so their browser can automatically point them to the new page of your choice.

重定向是网站向您的阅读器的浏览器发送快速消息,并告诉他们他们要访问的页面已移动的一种方式,因此他们的浏览器可以自动将他们指向您选择的新页面。

There are various different types of redirects such as 301 redirect, 302 redirect, 307 redirect, etc.

存在各种不同类型的重定向,例如301重定向,302重定向,307重定向等。

However to keep this article simple and useful, we will only cover 301 redirects as that’s the most important.

但是,为了使本文简单实用,我们将仅介绍301重定向,因为这是最重要的。

Let’s take a look at why it is important by understanding the use case.

让我们通过理解用例来了解为什么它如此重要。

您何时需要在WordPress中进行301重定向? (When do you need a 301 redirect in WordPress?)

The primary reason to use 301 redirects is when your site or a page on your site has been moved, and you want to point the user to a new page instead.

使用301重定向的主要原因是您的网站或网站上的页面已移动,而您想将用户指向新页面。

This article idea came to us when one of our readers asked us for a way to redirect users from an old post to a new post.

当我们的一位读者要求我们提供一种将用户从旧帖子重定向到新帖子的方法时,出现了这篇文章。

– You need to create a redirect when you are planning on deleting a post or page in favor of new content.

–当您计划删除帖子或页面以支持新内容时,需要创建重定向。

– You need to create a redirect when you are planning on changing the permalinks of your post or page.

–当您计划更改帖子或页面的永久链接时,需要创建重定向。

Why? Because not creating a redirect will cause your users to see a 404 not found error. Which is not only bad for users, but it can also impact your site’s SEO and hurt your search engine rankings.

为什么? 因为不创建重定向将导致您的用户看到404 not found错误。 这不仅对用户不利,而且还会影响您网站的SEO并损害搜索引擎排名。

That’s when 301 redirects become very important.

那时候301重定向变得非常重要。

It allows you to tell search engines and your user’s browser that the page they are trying to reach has been permanently moved to a new location.

它使您可以告诉搜索引擎和用户的浏览器他们试图访问的页面已被永久移动到新位置。

This allows for all your old page’s traffic and backlink (SEO) strengths to be transferred on to the new page.

这样,您所有旧页面的访问量和反向链接(SEO)优势都可以转移到新页面上。

Now that we have covered the why and when of redirects, let’s take a look at how you can create 301 redirects in WordPress using the different methods that are available.

既然我们已经介绍了重定向的原因和时间,让我们看一下如何使用可用的不同方法在WordPress中创建301重定向。

影片教学 (Video Tutorial)

演示地址

If you don’t like the video or need more instructions, then continue reading.

如果您不喜欢该视频或需要更多说明,请继续阅读。

如何在WordPress中创建重定向(使用插件) (How to Create Redirects in WordPress (using Plugins))

An easier approach to create and manage 301 redirects is by using one of the many WordPress redirect plugins. This allows you to setup redirects without ever writing a single line of code.

创建和管理301重定向的一种更简单的方法是使用许多WordPress重定向插件之一。 这使您可以设置重定向,而无需编写任何代码。

1.重定向 (1. Redirection)

The simplest way to add and manage redirects in WordPress is by using the Redirection plugin. Install and activate the plugin. Once activated, visit Tools » Redirection to setup your redirects.

在WordPress中添加和管理重定向的最简单方法是使用重定向插件。 安装并激活插件。 激活后,请访问工具»重定向以设置重定向。

Setting up WordPress redirects using Redirection plugin

Redirection plugin not only allows you to setup redirects, it also helps you find out 404 errors on your WordPress site. You can then redirect those URLs to an appropriate destination. See this tutorial on how to track 404 pages and redirect them in WordPress.

重定向插件不仅可以设置重定向,还可以帮助您在WordPress网站上找出404错误。 然后,您可以将这些URL重定向到适当的目的地。 请参阅本教程,了解如何跟踪404页面并在WordPress中重定向它们

2.页面链接到 (2. Page Links to)

Sometimes you may want to keep a post/page, but redirect it to another post or page. This is where Page Links to comes in handy. This simple plugin adds a meta box on your post edit screen where you can enter the address of the new location where you want to send your users.

有时您可能想保留一个帖子/页面,但将其重定向到另一个帖子或页面。 这是“页面链接”派上用场的地方。 这个简单的插件在您的帖子编辑屏幕上添加了一个meta框,您可以在其中输入要发送用户的新位置的地址。

Adding redirect link in post editor
3.简单的301重定向 (3. Simple 301 Redirects)

Another easy to use plugin is Simple 301 Redirects. As the name suggests, it makes 301 Redirects simple. Simply install and activate the plugin and then visit Settings » 301 Redirects to add your URLs.

另一个易于使用的插件是Simple 301 Redirects。 顾名思义,它使301重定向变得简单。 只需安装并激活插件,然后访问设置»301重定向即可添加您的URL。

Adding redirects using Simple 301 Redirects plugin for WordPress

Now while setting up 301 redirects using a WordPress plugin is easy, it has some minor performance setback. Based on your WordPress hosting provider, your WordPress redirects maybe a bit slower by some microseconds.

现在,虽然使用WordPress插件设置301重定向很容易,但它的性能会受到一些影响。 根据您的WordPress托管提供商 ,您的WordPress重定向可能会慢一些微秒。

If you want to make your redirects faster, then you can do so by using the code method and .htaccess file.

如果要加快重定向速度,则可以使用代码方法和.htaccess文件来实现。

使用.htaccess在WordPress中设置301重定向 (Setting Up 301 Redirects in WordPress using .htaccess)

Using the web server configuration file .htaccess, WordPress users can set up 301 redirects that are fast.

使用Web服务器配置文件.htaccess ,WordPress用户可以设置301快速重定向。

Please keep in mind that a small mistake in your .htaccess code can make your WordPress site inaccessible, and it may start showing Internal Server Error.

请记住,.htaccess代码中的一个小错误会使您的WordPress网站无法访问,并且可能开始显示Internal Server Error

That’s why it is important that you backup your .htaccess file before making any changes.

这就是为什么在进行任何更改之前备份.htaccess文件很重要的原因。

To edit your .htaccess file, you will need to connect to your website using an FTP client. The .htaccess file resides in your WordPress site’s root directory.

要编辑.htaccess文件,您需要使用FTP客户端连接到您的网站。 .htaccess文件位于WordPress网站的根目录中。

If you can’t see your .htaccess file there, then you need to force your FTP client to show hidden files. (See why you can’t find .htaccess file on your WordPress site.)

如果您在此处看不到.htaccess文件,则需要强制FTP客户端显示隐藏文件。 (看看为什么在WordPress网站上找不到.htaccess文件 。)

You can edit .htaccess file in any plain text editor like Notepad.

您可以在任何纯文本编辑器(如记事本)中编辑.htaccess文件。

Here is a simple redirect, where we are trying to send a user visiting an old post to a new post.

这是一个简单的重定向,我们试图将访问旧帖子的用户发送到新帖子。


RewriteEngine On
Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/

You can add the code above preferably at the end of your .htaccess file.

您可以将以上代码添加到.htaccess文件的末尾。

That’s all. We hope this beginner’s guide to creating WordPress redirects helped you setup redirects on your site.

就这样。 我们希望这份有关创建WordPress重定向的初学者指南可以帮助您在网站上设置重定向。

You may also want to check out these 9 most useful .htaccess tricks for WordPress.

您可能还需要查看WordPress的这9个最有用的.htaccess技巧

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/beginners-guide/beginners-guide-to-creating-redirects-in-wordpress/

wordpress 重定向

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值