This content originally appeared on Envato Tuts+ Tutorials and was authored by Rachel McCollin
In this post, I’ll show you how to redirect a page or URL in WordPress. You’ll learn how to set up automatic redirects, manual redirects, and wildcard redirects in WordPress.
What is a WordPress Redirect?
Ever clicked on a link expecting to land on a particular page, only to find yourself whisked away to a different one? That, my friend, is the magic of a WordPress redirect in action. It's like a digital sleight of hand where one URL deftly hands off to another. Now, why does this matter to you?
When you manage a website, pages sometimes get deleted, posts get updated, and whole websites undergo revamps. This is where WordPress redirects play a vital role. Think of them as the friendly traffic cops of the web, guiding visitors to the right destination when the original one is no longer available or has moved.
Redirects in WordPress are particularly important for maintaining a smooth user experience and preserving SEO rankings. Imagine you’ve put in loads of effort to rank a specific page. Without a redirect in WP, if that page moves, all your hard-earned SEO juice goes down the drain, and visitors hit a frustrating dead end.
There are various types of page redirects in WordPress, but the most common ones are 301 and 302. A 301 redirect is like saying, "Hey, this page has moved permanently. Update your records, please!" It's a firm, final move, signaling search engines to transfer the old page's SEO value to the new one.
On the flip side, a 302 redirect is more of a temporary detour sign, hinting, "We're just making some changes here. The original page will be back soon."
Why Redirect Pages or URLs in WordPress?
Now, you may be wondering why you need to learn how to redirect a page in WordPress. There are many times when you might need to redirect a post, page, or URL in WordPress. That’s when a WordPress redirect page comes in useful.
Maybe you’ve changed the slug for a post or page. Maybe you’ve amended your permalink settings. Or maybe you’ve written a new post and want to redirect an old post to that.
In all of these cases, you’ll need to learn how to redirect a post in WordPress. This tells browsers to go to the new URL instead of the old one.
Why Not Use Redirects in WordPress?
Setting up redirects in WordPress isn’t ideal. It slows things down for the user because the browser will go to the first URL, get the redirect message, and then go to the second URL. And there’s a risk that you’ll set up the redirect wrong or simply forget to do it after changing a URL. Not only that, but links coming through a redirected page aren’t worth as much for SEO -- Google just doesn’t value them as highly.
So it’s a good idea to avoid changing your URLs altogether. To minimize changing URLs, make sure you optimize them right from the start:
- Configure your permalink settings to use pretty permalinks when you first set up your site and before you add any posts or pages.
- Configure the slug for each post or page before you publish it. Make sure it’s suitable both for search engine optimization (SEO) and for user experience (UX).
- But if you haven’t already done this, and you need to redirect your URLs in WordPress, how do you do it?
How to Set Up Page and URL Redirects in WordPress
There are a few different ways to redirect URLs in WordPress. The kinds you’ll most likely be using are:
- automated WordPress page redirects
- manual redirects in WP
- wildcard WordPress page redirects
Let’s take a look at each of these WordPress redirects as they apply to directing a WordPress page or URL.
Setting Up Automated Redirects in WordPress
To set up a WordPress redirect page, you’ll need to install a plugin. In this guide, I’m going to show you how to do it with the WordPress Redirection plugin.
When you first install the WordPress page redirect plugin, it gives you the option to automatically track changes to URLs and to set up redirects. The link maker WordPress redirection plugin will also check the revisions to your existing posts and pages and set up redirects from old slugs you might have used for them.
In the screenshot below, it’s picked up on a change to an existing post’s slug and added a redirect from the old slug to the new one.
What if I make any changes to my slugs or URLs after activating? The link redirect maker plugin will track those and automatically set up the redirect to the new page. Below, you can see the WordPress page redirect plugin screen after making more slug changes.
Setting Up Manual Redirects in WordPress
Sometimes, the WordPress redirect plugin won’t pick up on the page redirect you need. Maybe you want your WordPress site to redirect one post to another or you want to redirect a URL on your domain to a different domain, but the WordPress redirect plugin won’t work for that.
In this case, you’ll need to set up a manual redirect in WordPress to forward pages without a plugin.
- Go to Tools > Redirection and scroll down to the Add new redirection section.
- In the Source URL field, type or paste in the URL you want to redirect from.
- In the Target URL field, type or paste in the URL you want to redirect to.
- In the Group field, either leave it as Redirections (the default) or select Modified posts if you’re directing from an old post to a newer version. This will tell browsers what kind of redirect it is.
- Finally, click the Add Redirect button, and your manual redirect will be added to the list of redirects. You've now completed all that you need to redirect a page in WordPress.
Setting Up Wildcard Redirects in WP
Use a wildcard redirect when you want to redirect a set of URLs that share certain elements. For example, if you change your permalink structure, a wildcard redirect will send anyone using a link from your old structure to the same link using your new structure.
If you’ve changed your permalink structure for posts from /blog/post-name to /category/post-name, for instance, you’ll need to use a wildcard redirect to ensure anyone using the old links is redirected to the new URL.
Wildcard redirects use something called Regex, which lets you create advanced redirects. You’ll need to enable Regex functions first to set up a wildcard WordPress redirect for pages. To use WordPress to redirect pages, complete the following process:
- Go to Tools > Redirection and scroll to the Add new redirection section of the screen.
- In the Source URL field, type the old path to categories, with a wildcard. It needs to take the form
/oldslug/(.*)$
. - The entry for Target URL needs to take the source
/newslug/$1
. - Then click the Add Redirect button.
Watch the Video and Learn How to Redirect in WordPress to Forward Pages
Wondering how to redirect a URL in WordPress? Knowing how to redirect a post in WordPress is a good tool to have. Here’s a quick video to learn more (and don’t forget to subscribe to the Tuts+ YouTube channel for more daily videos!):
The Best WordPress Themes and Plugins on Envato Market
Explore thousands of the best WordPress themes ever created on ThemeForest and leading WordPress plugins on CodeCanyon. Purchase these high-quality WordPress themes and plugins and improve your website experience for you and your visitors.
Get More WordPress Resources
Now you know how to redirect a URL in WordPress. Here are a few of the best-selling and up-and-coming WordPress themes and plugins available for 2022.
Redirect in WordPress the Proper Way
If you change the URLs in your WordPress site or create a new post to replace an old one, you’ll need to set up a redirect in WordPress to forward pages. Depending on the changes you’ve made, you might use an automatic redirect, manual redirect, or wildcard redirect. Hopefully, this guide has helped you to learn how to set up redirects in WordPress for different circumstances.
This content originally appeared on Envato Tuts+ Tutorials and was authored by Rachel McCollin
Rachel McCollin | Sciencx (2021-05-25T07:40:54+00:00) How to Redirect a Page or URL in WordPress. Retrieved from https://www.scien.cx/2021/05/25/how-to-redirect-a-page-or-url-in-wordpress/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.