Want to learn how to implement 301 Redirect in WordPress? You’ve come to the right place!
The 301 redirect is an important tool for website owners. It is the most efficient way to redirect a user from one page to another permanently. This is especially helpful when you are redesigning or restructuring your website, as it will ensure that any users who accessed the old page will be directed to the correct new page.
Using a 301 redirect is essential when you need to move content to a new URL or domain, switch to HTTPS, permanently delete a page on your website, or merge websites. To implement a 301 redirect in WordPress without plugins like Yoast Premium, you can use the built-in WordPress function or utilize a PHP function.
If these concepts are unfamiliar to you, don’t worry – this article aims to guide you through the process of implementing 301 redirects in WordPress. Additionally, if you’re searching for WordPress hosting, HostAdvice can help you find the best options on the market.
- The redirect code should include the original URL and the destination URL, and should be preceded by the code for a 301 redirect
- Website owners can test the redirect by entering the original URL into a web browser and confirming that it redirects to the correct destination URL
- There are several redirect plugins available for WordPress, and website owners should choose one that meets their needs
- Website owners should avoid creating redirect chains and instead redirect URLs directly to their final destination
- Using relative URLs in the redirect code can make the redirects more flexible and easier to maintain
Definition of 301 Redirect
A 301 redirect is a permanent redirect from one URL to another URL. It is like a change of address notice for your audience or the internet.
Imagine your company moved to a new building and want to make sure your customers are aware of the new address. A 301 redirect works in the same way for WordPress websites. You can use it to redirect visitors and search engines to a new URL when the original URL has been changed or moved.
Importance of 301 Redirect in WordPress
301 redirect is crucial for maintaining the SEO value of the original URL, as it transfers the page rank from the old URL to the new URL. It also helps to avoid broken links, which can lead to a poor user experience and negatively affect website traffic and search engine rankings.
Identify Urls That Need to Be Redirected
Before implementing a 301 redirect, it is important to identify the URLs that need to be redirected. There are two primary ways to identify these URLs: using Google Analytics or Search Console and using a redirect plugin.
1. Use Google Analytics or Search Console
Google Analytics and Search Console are free tools provided by Google to help website owners track and analyze their website’s performance. By using these tools, website owners can identify any URLs that are receiving traffic or have backlinks but are no longer in use and can then redirect these URLs to a new page or post.
2. Use a Redirect Plugin
A redirect plugin is a tool that can automatically identify broken links or 404 errors on a website and redirect them to a new page or post. Using a redirect plugin can save time and ensure that all broken links are identified and redirected, but it is important to test each redirect to ensure it is working correctly.
Choose a Method to Implement a 301 Redirect
There are two primary ways to implement a 301 redirect in WordPress: manually or using a plugin. Both methods have their advantages and disadvantages, and WordPress website owners should choose the method that works best for them.
Manual Method
The manual method involves accessing the website’s .htaccess file and adding the redirect code directly. This method can be more technical and requires more knowledge of website development, but it can be faster and more reliable than using a plugin. You can use it whenever you need to move an entire website to a new domain, but your website must be hosted on an Apache server.
1. Access .Htaccess File
The .htaccess file is a configuration file used by web servers to control the behavior of the website. The file can be accessed using a file transfer protocol (FTP) client or a file manager in the website’s hosting account.
To access .htacccess file using File manager, follow these steps:
- Login to your web hosting’s account control panel and locate the file manager
- Navigate to the root directory, which is typically named “public_html”, “www”, or “htdocs”
- Click the settings button on the upper right-hand corner of the File manager to “Show Hidden Files (dotfiles)”
- Find the .htaccess file once-hidden files are visible. If the file doesn’t exist, click the “New File” or “Create File” button in your file manager with a new file name (.htaccess)
- Edit the .htaccess file by right-clicking on “Edit” or “Code Edit”, depending on the control panel you are using
To access .htacccess file using FTP client, follow these steps:
- Download and install an FTP client like FileZilla or Cyberduck on your computer
- Obtain your FTP credentials such as FTP server address, username, and password to connect
- Open the FTP client and add credentials
- Input 21 for port number if the FTP client request for it before connection
- Connect to the web server by clicking the “connect” button
- Navigate to the root directory \
- Show and locate hidden files
- Edit and upload the .htaccess file
2. Add the Redirect Code
After accessing the .htaccess file using any of the steps above, the redirect code needs to be added using the proper syntax. The code should include the original URL and the destination URL and should be preceded by the code for a 301 redirect.
To add the redirect code to the .htaccess file, follow these steps:
- Right-click on the file and choose view/edit to open the .htaccess file in a text editor
- Add the 301 redirect code using the syntax (Redirect 301 /old-url-path /new-url-path)
- Replace “/old-url-path” with the relative path of the old URL, and “/new-url-path” with the relative path of the new URL. For example, if you want to redirect from “mysite.com/old-page” to “mysite.com/new-page”, the code would look like this: Redirect 301 /old-page /mysite.com/new-page
- After adding the redirect code to “Request” and “Destination”, Click save changes
3. Test the Redirect
After adding the redirect code, it is important to test the redirect to ensure it is working correctly. You can test the redirect by entering the original URL of your website into a web browser and confirming that it redirects to the correct destination URL.
Plugin Method
The plugin method involves installing a redirect plugin and using its interface to set up the redirects. This method can be easier and more user-friendly than the manual method but may not be as reliable in some cases. You can use the plugin method to create 301 redirects whenever you are using WordPress, easy management of multiple redirects, avoid editing .htaccess files, and for added features like tracking broken links.
1. Install a Redirect Plugin
There are several redirect plugins available for WordPress, and website owners should choose one that meets their needs. Some of the popular redirect plugins include Redirection, Simple 301 Redirects, and Yoast SEO.
To install and activate the plugins above, follow the steps below:
- Log in to your WordPress dashboard
- On the left-hand menu, navigate to Plugins and click on “Add New”
- Search for your preferred redirect plugins (Redirection, Simple 301 Redirects, and Yoast SEO)
- Click the “Install Now” button and “Activate” Plugin after installation.
- Complete the setup of the plugin
- Follow the Plugin’s instructions to create a 301 redirect. Each plugin has a different interface and process, but generally, you will be asked to provide the old URL (source) and the new URL (target).
2. Add the Redirect Url and Destination Url
After installing the plugin, website owners can add the redirect URL and destination URL using the plugin’s interface. The redirect URL is the original URL that needs to be redirected, and the destination URL is the new URL that the redirect should point to.
3. Test the Redirect
After setting up the redirect, it is important to test it to ensure it is working correctly. Website owners can test the redirect by entering the original URL into a web browser and confirming that it redirects to the correct destination URL.
Best Practices for Implementing a 301 Redirect
While implementing a 301 redirect can be helpful for maintaining SEO rankings and user experience, it is important to follow best practices to ensure the redirects work properly and do not cause any issues.
Avoid Redirect Chains
A redirect chain is when a URL is redirected multiple times before reaching its final destination, which can slow down page load times and negatively impact SEO.
Website owners should try to avoid creating redirect chains and instead redirect URLs directly to their final destination. To avoid redirect chains, always direct the old URL to its final destination URL, update internal and external links, plan your URL structure to avoid future changes, and use a redirection plugin to identify and fix redirect chains.
Use Relative Urls
Using relative URLs in the redirect code can make the redirects more flexible and easier to maintain. It can also prevent issues if the website’s domain or URL structure changes in the future.
To create a 301 redirect using relative URLs, you will need to view and edit the .htaccess file in the root directory of your website. To do this, replace old-relative-url with the relative URL path of the old page (excluding the domain), and new-relative-url with the relative URL path of the new page.
Update Internal Links
After implementing a 301 redirect, website owners should update any internal links that pointed to the old URL to point to the new URL. Updating internal links can help ensure a better user experience and prevent any confusion or frustration for website visitors.
Conclusion
301 redirects alerts the visitor/browser that the page or post requested has been permanently moved to a new content or URL.
As a website owner, implementing 301 redirects is an important skill you might need to update your URL or domain, redirect deleted or outdated pages to relevant content pages and switch from HTTP to HTTPS. Don’t forget that you can implement 301 redirects in WordPress by modifying the .htaccess file or using free and premium redirect plugins like Redirection and Yoast Premium.
Now that you’ve learned how to implement 301 Redirect in WordPress, learn what to do next!
Next Steps: What Now?
- Read our Godaddy WordPress Hosting Review