WordPress websites非常适合扩展业务。它们具有灵活性,可自定义,无编码(如果您愿意的话),并且可以为您想要完成的任何操作安装插件。

As your site scales, redirects become an inevitability. You’ll eventually need to start implementing them to ensure that visitors and search engines are routed to the pages they’re looking for and away from an error page. It’s best to learn how they work now than scramble tofix a broken link在路上。

Fortunately, creating redirects in WordPress is straightforward as long as you know what you’re doing. In this guide, you’ll learn what redirects are, how they support a good user experience and SEO strategy, when and why you’ll need to add them, and two methods to create redirects in WordPress.

Grow Your Business With HubSpot's Tools for WordPress Websites

There are several types of redirects, but, unless you’re a web developer, you only really need to know about two: 301 (permanent) redirects and 302 (temporary) redirects.

A 301 redirect is the one you’ll probably be using most. This redirect is permanent, meaning that a web page has been moved to a new location and you don’t plan to move it back to the original location. 301 redirects are also the best option to preserve search engine authority, which we’ll discuss later on.

A 302 redirect indicates that the new URL is temporary, and that youplan to move the web page back to its original location at some point. A 302 redirect may be used for updating or repairing web pages — for example, sending users to an alternative page while you fix a broken page — but it’s far less common than a 301 redirect.



Generally, you should use a 301 redirect whenever you’re moving a web page on your site from one URL to another URL and want to send any web traffic from the old URL to the new URL. If you don’t set up a redirect, users will receive a 404 (not found) error when visiting the old URL.


  • 更换过时的页面:If you’ve added a new page to your website that serves more up-to-date content than another page, you can redirect the old page URL to the new one.
  • Removing a page from your site:If you plan to remove a page from your site, remember that URLs don’t just go away — search engines and some visitors will have saved the link to this removed page. To prevent a 404, redirect the URL of the removed page to a similar page, the home page, or a page that tells users the product or content is no longer available.
  • Changing your website structure:重新组织网站的结构涉及四处移动页面,这可能需要一个或多个重定向,以确保将访问者发送到正确的页面。
  • 更改永久链接:You may want to change your permalink structure so your URLs看起来更专业, are easier to read, and帮助您的SEO。In this case, redirect your old URLs to your new, updated URLs to prevent broken links.
  • 更改域名:If you get a new domain name, this will be reflected in your URL. Old URLs should be redirected to URLs containing your new domain name.
  • 将多个域路由到一个页面:To capture wayward traffic, website owners may purchase domain names that are similar to their primary domain name. This way, if a visitor types in the wrong domain, they’ll be redirected to the right website. This also keeps competitors from buying up similar domains and stealing traffic.
  • Saving an email campaign:Say you’ve sent out an email blast that contains a broken link … oops. While you can’t change the link in the email, you can redirect the broken URL to the correct URL. Crisis averted.

Why You Should Use Redirects in WordPress


User Experience

实施重定向的最明显原因是防止与您网站的断开链接。这些导致404个错误,导致用户体验差。您可能已经发生了这种情况 - 单击反向链接或旧书签,然后被带到错误页面。烦人,对吧?301重定向阻止这种情况发生。

If visitors do happen to find a broken URL, you can improve things a bit by creating a定制404页这会招待(甚至可以转换)访客,如这样:

a 404 page for a marketing agency website


This should only be a last resort as it’s still a poor user experience. Ideally, visitors should never have to reach this page. Why bother searching your site for the content they want when they could just as easily head to a competitor’s?



The more insidious consequences of 404s are their effects on yourWordPress SEO。毕竟,不仅仅是人类accessin游客g your website. Search engine crawlers are regularly pinging your website to index your content and site structure.

If one of these bots finds a 404, it will dock points from your site’s authority — search engines don’t want to recommend websites that appear broken or missing important resources. And, again, a clever 404 page won’t save you here.

通过适当地实现一个301重定向,搜索gines will know that your page was permanently moved or removed, and you’ll send bots to the correct page to avoid the broken link. As a result, your new URL will be properly indexed by these bots.

Additionally, another key benefit of permanent redirects is that they preserve the search ranking of the old URL. For instance, if you own a landing page with high authority and change its URL, the new URL will retain the authority of the old URL. The ranking of your landing page should not be affected significantly if at all.

Now that we know when and why to use redirects in WordPress, let’s learn how: First, we’ll discuss the plugin method, then an alternative manual method.

How to Redirect a URL in WordPress With a Plugin

A plugin is the simplest way to implement and monitor your WordPress website redirects, especially if you refrain from modifying WordPress files yourself.

有许多WordPress redirect plugins所有这些都类似地工作,使您可以创建基本的301重定向以及更复杂的站点重定向。有些还跟踪重定向,告诉您每个命中次数有多少次,并提醒您任何问题。

Here, we’ll be covering how to set up 301 redirects with two popular plugins, Redirection and All in One SEO.



1。Install and activatethe Redirection plugin.

2。In your dashboard, select工具>重定向

3。On the welcome screen, clickStart Setup

welcome page for the wordpress redirect plugin redirection

4。On the next screen, you can choose to allow Redirection to create automatic redirects when you change permalinks. You can also choose whether you’d like the plugin to log 404 errors and redirects on your site. Choose your preferences, then click继续设置


5。Next, Redirection will test its connection with theWordPress REST API。Once this test is successful, you can clickFinish Setup, 然后Finished!

6。You’ll be brought to the main Redirection page (工具>重定向) in your dashboard. Here, you can view all current redirects, as well as a log of redirect activity and 404 errors.

main redirects page for the wordpress redirect plugin redirection

7.要添加新的重定向,请首先粘贴您要重定向的URLSource URL字段。

8.将您要重定向到的URL粘贴到Target URL字段。

creating a redirect with the redirection plugin

9.By default, this will create a 301 redirect. To create a different redirect or to toggle advanced settings, click the cog icon. You can give your redirection a title, matching criteria for the redirect, and/or an action when a match is found.

10.When finished, clickAdd Redirect。You’ll see your new redirect added to the list. To test your redirect, click检查重定向并看到您已连接到目标URL。If you have logging turned on, you’ll see this activity by clickingLogabove.

a completed redirect in the redirection plugin

All in one SEO

All in One SEO(AIOSEO) is another popular, powerful plugin to help you improve your search ranking. The Pro and Elite versions of the AIOSEO include a redirection manager that finds broken links and sets 301 redirects for them. You can also create redirects yourself through the plugin.

To create a 301 redirect with AIOSEO:

1。Install, activate, and set up the AIOSEO plugin.

2。In your dashboard, select全部seo>重定向。您将被带到重定向tab.

main redirect page in the wordpress redirect plugin all in one seo


3。Paste the URL you want to redirect from into theSource URL字段。离开你的域名和之前的一切e it out of the URL. For example, if your source URL is “https://www.example.com/old-page/”, only paste “/old-page/”. Into the field

4。将您要重定向到的URL粘贴到Target URL字段。该URL可以是相对URL或绝对(即完整)URL。

5。In theRedirect Type下拉,选择301 Moved Permanently

6。点击Add Redirect


redirection list in the wordpress redirect plugin all in one seo


How to Manually Redirect a URL in WordPress

If you’re comfortable editing server files directly, it’s also possible to set up redirects manually.

For this method, we’ll be modifying。htaccess,在大多数WordPress网站上找到的配置文件。编辑此文件时要谨慎,因为即使是小型错别字也可能会破坏您的网站。我们推荐making a backup of your current sitebefore going forward, just in case something goes wrong.

另外,请确保您可以直接修改服务器文件 - 检查托管提供商的文档或联系支持,以了解如何处理重定向。

To create a permanent redirect in .htaccess:

1。Go to your server filesystem. There are multiple ways to do this:

  • 通过您的托管帐户的控制面板,例如CPANEL
  • through anFTP客户端
  • 通过WordPress文件编辑器


3。Open .htaccess in a text editor (depending on what tool you’re using, you may need to download the file to your computer).


# 301 redirect - single page
Redirect 301 /old-page


… 在哪里/旧页是原始页面的相对URL,https://www.example.com/new-page/is the absolute URL of the target page.

5。To permanently redirect an entire site to another domain, paste the following code at the end of your .htaccess file:

#301重定向 - 网站范围内

Redirect 301 / https://example.com/

… 在哪里https://example.com/is the new website’s URL.



Send your users to the right place.

重定向are one of those tools that all website owners should know how to use. At some point, you’ll come across an instance when you’ll need to scrap one URL for another. However, URLs don’t just disappear, which is why redirects are so important for keeping your WordPress website healthy.

You’ve already done a lot to build authority in your space — don’t let broken links undo all of that work. Redirects are quick and simple, and they preserve your standing with visitors and search engines alike.

Use HubSpot tools on your WordPress website and connect the two platforms  without dealing with code. Click here to learn more.

Use HubSpot tools on your WordPress website and connect the two platforms  without dealing with code. Click here to learn more.

Originally published Nov 8, 2021 7:00:00 AM, updated November 08 2021