This tutorial explores using 301 Redirects to move a page to a new URL. We cover how to implement a 301 Redirect in WordPress in 4 easy ways, including redirection and SEO plugins, editing the .htaccess file, and using PHP script. Let’s get started.
If you’re updating your link structure or moving your WordPress site to a new domain, it’s important to set up 301 Redirects. This lets you permanently redirect a page to a new URL without losing its SEO value and rankings.
Table of Contents
What Is A 301 Redirect in WordPress?
Before we discuss a 301 Redirect, let’s look at what Redirects are. When you visit a website, each link you click or page you open has a specific address, called a URL.
Sometimes, websites change or remove a page, which leads to a 404 error or a “Page Not Found” error. This is where Redirects are handy. A Redirect helps visitors and search engines find the right page if the original one has been moved, renamed, or deleted.
These Redirects are important for keeping a website user-friendly and organized. They prevent 404 errors, which can make users leave your site. By setting up Redirects, you guide users to the correct page, keeping them happy and engaged. This ultimately reduces the bounce/exit rate.
A 301 Redirect in WordPress is a permanent redirection that automatically sends your audience and search engines from an old URL to a new one. It helps when you’ve updated a page URL, moved content, or restructured your site, ensuring anyone visiting the old link is sent to the correct page.
When you use a 301 Redirect, you let search engines know where the new page is. This helps keep any ranking or SEO value from the old page intact so your site can maintain its position on search results.
There are a few types of Redirects:
- 301 Redirect: Permanent Redirect, transferring SEO power from the old URL to the new one.
- 302 Redirect: Temporary Redirect. It doesn’t transfer SEO value since the change isn’t permanent.
- 303 Redirect: This is a non-cacheable WordPress Redirect to replace content temporarily; commonly used for “see other” pages.
- 307 Redirect: Indicates to search engines that the Redirect might be updated.
- 308 Redirect: Permanent Redirect like 301 but keeps the request method intact.
- Meta Refresh: Client-side Redirect with a delay; often used in HTML but less SEO-friendly than server-side Redirects.
However, 301 Redirect is the most used Redirect type.
When to Use 301 Redirect in WordPress
A 301 Redirect in WordPress is essential whenever you permanently change a URL. When you use this Redirect, you ensure visitors and search engines end up on the correct page without running into “Page Not Found” errors. Here are some key situations where you’d want to use WordPress 301 Redirect:
Change URL Structure
Sometimes, you may update your site’s URL structure to make it more user- or SEO-friendly. For example, changing from yourwebsite.com/blog/post123 to yourwebsite.com/blog/best-seo-tips can make the URL clearer and more relevant for search engines.
When you modify URLs like this, you must set up a 301 Redirect from the old URL to the new one. When you do this, any traffic or backlinks pointing to the old URL will automatically lead to the updated page.
Move to a New Domain
If you’re rebranding or redirecting to a different domain (like from “oldsite.com” to “newsite.com”), using 301 Redirects is essential. Redirects from every page on the old domain to the corresponding page on the new domain allow you to keep visitors and avoid losing SEO value.
Moreover, search engines see the 301 Redirects as a permanent move, allowing the new domain names to inherit the SEO benefits, backlinks, and ranking power of the old one, which helps you retain your search position after the switch.
Switch from HTTP to HTTPS
Transferring your website from HTTP to HTTPS is essential for website security and SEO, as HTTPS improves trust and search engine rankings. To ensure search engines recognize the new secure version, 301 Redirects direct users and search engines from HTTP pages to HTTPS versions, consolidating all traffic to the secure URLs.
Delete or Merge Content
Suppose you delete a page or post because it’s outdated or redundant, and you don’t want visitors hitting a dead-end 404 page. In this case, creating a 301 Redirect from the old page to a relevant new one or the homepage may keep users engaged.
Additionally, if you’re merging two similar posts or pages into one for simplicity, using a 301 Redirect helps route all traffic to the new, combined page. This maintains a good user experience and combines the SEO power of both pages.
Improved SEO
If you’ve significantly updated a post or created new content that is more comprehensive, you might want to redirect traffic from the old page to this new, improved page. In this case, a 301 Redirect ensures visitors see the most up-to-date information, boosting engagement and reducing bounce rates.
By redirecting to the improved content, you’re helping search engines understand that the newer page is the more valuable resource, which can help in better rankings.
Fix Broken Links
Broken links can hurt your SEO and disrupt the user experience. If you notice any broken or outdated links in older posts, you can set up 301 Redirects to point these links to active, relevant pages. Redirecting broken links ensures visitors reach useful content on your site, making for a smoother browsing experience while showing search engines that your site is well-maintained.
Minimized Duplicate Posts
When multiple URLs link to the same content, it may be difficult for search engines to determine the primary version. Redirecting duplicate URLs to the chosen version helps boost the visibility of your WordPress blog.
In all these cases, a 301 Redirect helps preserve your site’s SEO authority, ensures a smooth visitor experience, and prevents any disruptions caused by URL changes. Setting these up in WordPress keeps users and search engines happy, helping maintain your site’s performance and reputation.
Now that you know what a 301 Redirect is and when you should use it, let’s learn how to implement 301 Redirects in WordPress.
4 Ways to Set up 301 Redirect in WordPress
In this section, we show you 4 methods to create 301 Redirects in WordPress:
- Using a Redirection Plugin
- Using an SEO Plugin like RankMath
- Editing .htaccess File
- Using a PHP Script.
Using a Redirection Plugin
Using a plugin is the easiest way to manage redirects in WordPress, especially if you’re uncomfortable with code. Many WordPress plugins are designed specifically for Redirects; they allow you to manage everything within your WordPress dashboard. One popular option is the Redirection plugin.
This free tool provides a Redirect Manager for your site. It lets you create a 301 Redirect in WordPress, monitor broken links, migrate permalink changes, and more. Here’s how you can use it to set up a 301 Redirect:
Go to your WordPress dashboard. Then, navigate to Plugins → Add New Plugin, and search for “Redirection”. Install the plugin and activate it. After activation, go to Tools → Redirection in your WordPress dashboard.
Click Start Setup on the welcome page.
On the next screen decide if you want to monitor permalinks, keep a log of 404 errors and all Redirect logs, and store IP details for redirects and 404. If so, check all these options (as shown below) and click Continue.
It will start testing the REST API. This is necessary because the Redirection plugin uses WordPress REST API to communicate with WordPress. Remember, you need at least one working REST API to continue. Once the test is passed and you get a “Good” rating, click Finish Setup.
Important:
REST API can be blocked by a security plugin, a server firewall, caching software like Cloudflare, or other plugins that conflict with REST API. If you experience issues, consult your plugin documentation or contact your host support.
Next, wait a few moments for Redirection to get installed. Once it’s done, click Continue.
Then, click Ready to begin!
In the Redirection dashboard, go to the Add new redirection area and fill in the Source URL (the URL you want to redirect from, e.g., /old-page) and Target URL (the URL you want to redirect to, e.g., /new-page).
After that, click Show advanced options (represented with a gear icon) to expand additional settings.
Select 301 – Moved Permanently HTTP code and click Add Redirect to save your changes.
Once done, visit the original URL to ensure it correctly redirects to the new page. This step helps you confirm that the Redirect is set up properly.
Hosted.com’s WordPress Hosting plans come with a comprehensive set of features designed to meet all your needs, including powerful tools and advanced settings.
Plus, you’ll have access to expert support every step of the way to keep your website performing at its best.
Using an SEO Plugin
Another easy way to set up a 301 Redirect in WordPress is using an SEO plugin like Rank Math. SEO plugins often have built-in redirection tools that make managing your Redirects quick and simple. Here’s how to do it:
First, install the RankMath plugin and go through the basic setup wizard. Then, go to Rank Math SEO → Redirections in your WordPress dashboard and click Add New.
Now, you’ll see an Add Redirection form. Provide source and destination URLs. You can provide multiple source URLs here. Check the Ignore Case option if you want to make it case insensitive. Then, select the Redirection Type – 301 Permanent Move in our example. Ensure you set the Status to Activated; otherwise, the redirection won’t work. Lastly, click Add Redirection.
The Redirect will now appear in your list of active Redirects in the Redirection dashboard. To test this 301 Redirect in WordPress, open a new browser tab and enter the source URL to confirm it redirects to the destination URL. If it works, your redirect is successfully set up!
Important:
The Redirection option is not enabled by default in the RankMath plugin. If you don’t see this option under Rank Math SEO, you can enable it by navigating to Rank Math SEO → Dashboard.
Editing the .htaccess File
If you don’t want to use a plugin to create a 301 Redirect in WordPress, you can edit the .htaccess file directly. The .htaccess is a configuration file used by your web server, and it controls how your website behaves. If you add a few lines of code to this file, this will create permanent Redirects.
However, be careful when editing the .htaccess file, as mistakes can break your site. So, create a website backup before you make any changes to the .htaccess file.
You can edit .htaccess file in two ways:
Here’s how you can do that using the Hosted.com File Manager feature:
First, log in to your Hosted control panel (cPanel). Then, navigate to Files → File Manager.
Go to the public_html folder. Then, select the .htaccess file and click Edit at the top to open this file in cPanel’s built-in editor. We recommend downloading a backup of the .htaccess file. This way, you can restore this file if something goes wrong.
Now that you’ve accessed the .htaccess file, you can add code for different Redirects. Here are 3 common examples:
Redirect Single URL
If you want to redirect one specific page (like /old-page to /new-page), add this line of code under RewriteEngine On line in your .htaccess file:
Redirect 301 /old-page https://www.yoursite.com/new-page
This tells the browser that the old URL has permanently moved to the new URL. Ensure you replace /old-page and https://www.yoursite.com/new-page with the actual page paths.
Redirect Multiple URLs
To redirect multiple URLs using the .htaccess file, add multiple lines of Redirect code for each URL you want to redirect. Here’s how:
Redirect 301 /old-page1 https://www.yoursite.com/new-page1
Redirect 301 /old-page2 https://www.yoursite.com/new-page2
Redirect 301 /old-page3 https://www.yoursite.com/new-page3
Alternatively, you can also redirect multiple old URLs to one new URL as follows:
Redirect 301 /old-page1 https://www.yoursite.com/new-page3
Redirect 301 /old-page2 https://www.yoursite.com/new-page3
Redirect a Whole Domain
If you’ve changed your domain name and want to redirect all traffic from the old domain to the new one (like from olddomain.com to newdomain.com), use this code:
RewriteCond %{HTTP_HOST} ^yourolddomainname.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yourolddomainname.com [NC]
RewriteRule ^(.*)$ https://yournewdomainname.com/$1 [L,R=301,NC]
This code takes all traffic from the old domain and sends it to the new domain. Also, you’ll now see your new domain name in the browser’s address bar. Ensure you replace yourolddomainname.com and yournewdomainname.com with your actual domains.
Important:
If you’re wondering about various other ways to redirect a domain to another domain, you may refer to our detailed tutorial titled:
How to Redirect a Domain to Another Domain: Best Practices
Once you’ve added the necessary code, save the .htaccess file and test the Redirect. For this, visit the old URL in your browser to see if it takes you to the new location. If it works, you’ve successfully set up the Redirect.
Redirect Using a PHP Script
Setting up a 301 Redirect in WordPress using a PHP script allows you to permanently direct search engines and visitors from old URLs to new ones.
PHP redirects are server-facing, so this is a more manual and technical method that requires some PHP coding knowledge, making it ideal for advanced users who need to manage multiple Redirects in WordPress. By using PHP, you gain full control over your Redirect.
Here’s how Hosted.com users can do it:
Open your web browser and type https://yourdomain.com/cpanel (ensure you replace yourdomain.com with yours). A login screen will appear asking for your cPanel credentials, which your hosting provider usually provides when you set up your account.
Enter your cPanel username and password, and click Log In.
Once you’re in, go to Files → File Manager. This will open the file management system where you can access and edit your site files. Now that you can access your site’s files, create the PHP script. To do that, open the public_html folder containing all your WordPress files. Then, click +File in the top-left corner.
In the opened pop-up, name this file permanent_redirects.php and click Create New File.
Now, select the permanent_redirects.php file and click Edit at the top. This will open your file in an editor.
To set up the Redirect, add the following code to the PHP file:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.newdomain.com/new-url/");
exit();
?>
Ensure you replace https://www.newdomain.com/new-url/ with the actual URL where you want visitors to be redirected.
Important:
Don’t forget to include exit() function at the end of the specified header. Without this, search engines may process your original page and ignore your new Redirect. If you need to set up multiple Redirects, add blocks of the above code for each URL you want to redirect. This gives you the flexibility to manage several pages efficiently.
Once you have entered the code, click Save Changes at the top right of the editor to save the PHP file.
To verify your Redirect is working, open your browser and type in the URL of the PHP script you just created. It should look something like this: https://www.yourwebsite.com/permanent_redirects.php. If the Redirect is set up correctly, you will be taken to the new URL specified in the script.
Testing the Redirect is important to ensure everything is working. If it doesn’t work, recheck the code for typos or mistakes.
Important:
Always double-check your code for typos or errors. Even a small mistake can cause website issues or prevent the Redirect from functioning properly. Test each Redirect thoroughly before deploying it. This helps ensure visitors and search engines are directed to the correct pages without errors.
Before you proceed with any major changes, like setting up a 301 Redirect in WordPress, create a site backup. This will help you to restore your website if anything goes unexpected during the process. Hosted.com offers daily backups on all WordPress hosting plans, so you can easily protect your website files.
In addition, Hosted.com also provides several features to enhance your WordPress site. These include:
- Unlimited SSL certificates to secure your site
- One-click WordPress installation for easy setup
- LiteSpeed cache for better performance and faster loading times.
- Free domain registration on all hosting plans (excluding the WordPress Pioneer package)
- Free access to a library of WordPress tutorials, providing the guidance you need to manage and grow your website.
Troubleshoot Common 301 Redirect Issues
Sometimes, 301 Redirects can cause problems like Redirect chains or Redirect loops. A Redirect chain happens when one URL redirects to another, and then that second URL redirects to a third one.
This creates a sequence that can slow down your website and confuse search engines, affecting SEO and user experience. However, a Redirect loop occurs when two URLs keep redirecting to each other, trapping the user in an endless cycle.
To detect and fix these issues, use tools like HTTP Status Checker. This can help you identify unnecessary Redirects and ensure everything works smoothly.
Avoid Common Mistakes
To set up Redirects correctly, it’s important to avoid common mistakes. First, know the difference between 301 and 302 Redirects. A 301 Redirect is permanent, telling search engines to update their records, while a 302 is temporary, keeping the original URL indexed.
Next, maintain proper Redirect chains by avoiding multiple Redirects in a row. Directly linking the old URL to the new one ensures a smooth flow. Lastly, always redirect to relevant content so users find what they’re looking for, keeping visitors and search engines happy.
KEY TAKEAWAYS
- 301 Redirects help keep your site’s SEO strong by permanently sending visitors from old URLs to new ones.
- You can use plugins like Redirection or SEO tools like Rank Math to set up Redirects easily.
- Editing the .htaccess file is a manual method for those comfortable with coding.
- PHP Redirects offer another option but require careful handling.
- Avoid Redirect chains and loops to maintain site speed and SEO.
- Always redirect users to relevant pages so they can find the right content.
FAQs
What is a 301 Redirect htaccess?
A 301 Redirect in the .htaccess file permanently moves one URL to another directly at the server level, preserving SEO value.
Why should I use a 301 Redirect in WordPress? And what happens if I don’t set up a 301 Redirectwhen changing a URL?
Setting up a 301 Redirect preserves your website’s SEO rankings and ensures users don’t encounter broken links, improving their experience. However, if you don’t do this, visitors will encounter 404 errors, and search engines may see it as a broken link, causing your SEO rankings to drop.
Can I set up 301 Redirects without a plugin?
Yes. You can manually edit the .htaccess file or use PHP code if you prefer a coding approach.
Which plugins are best for creating 301 Redirects?
Popular plugins include Redirection, Rank Math, and Yoast SEO; all offer simple ways to set up and manage Redirects.
Can too many 301 Redirects slow down my site?
Yes, especially if there are long Redirect chains. It’s best to keep Redirects direct and minimal to maintain site speed.
Other Related Tutorials & Blogs:
– 403 Forbidden Error Explained: Easy Fixes for Your Website
– How to Fix 502 Bad Gateway Error in WordPress
– How to Fix the WordPress 500 Internal Server Error
– How To Fix ERR_UNKNOWN_URL_SCHEME Error
– WooCommerce Shortcodes: A Guide to Their Uses & Benefits
- About the Author
- Latest Posts
Rhett isn’t just a writer at Hosted.com – he’s our resident WordPress content guru. With over 6 years of experience as a content writer, with a background in copywriting, journalism, research, and SEO, and a passion for websites.
Rhett authors informative blogs, articles, and Knowledgebase guides that simplify the complexities of WordPress, website builders, domains, and cPanel hosting. Rhett’s clear explanations and practical tips provide valuable resources for anyone wanting to own and build a website. Just don’t ask him about coding before he’s had coffee.