Do you know How to redirect a page in WordPress? No?
No worries, In today’s tutorial we are going to see How to redirect a page in WordPress.
You can easily make 301 redirects in your WordPress website to avoid 404 pages and improve your user’s experience on your site.
What is Redirection in WordPress?
When we talk about redirects. we usually mean to point one URL to another. Whenever a reader on your site, tries to access the content that has been moved to another URL.
Your site will send a quick message to the user’s browser that this URL has moved to this one(New URL).
And the browser then accesses that new URL and the user can view or access the content on that particular page.
There are many types of redirects like 301 redirects, 302 redirects, 307 redirects, etc.
In today’s tutorial, We’ll be discussing the 301 redirects which are also called permanent redirects.
What is 301 Redirect?
Let’s say, you had a page on your site having URL https://example.com/blog and that page has been moved to a new URL which is https://example.com/tech-blog, now whenever your users will visit the old URL (https://example.com/blog), they’ll see a 404 error.
So, we create a permanent redirect in order to give the users, what they are looking for. Now, whenever your user will visit that old URL, they’ll be redirected to the new one.
Having 404’s on your site is not a good practice in terms of SEO. For good rankings, you should avoid such errors and always tries to redirect pages in WordPress, if you have changed its URL.
Such 404’s can cause you to lose some valuable backlinks if your site has multiple 404 errors. This alternatively will affect your site’s ranking and Domain Authority.
So to avoid such situation we use 301 permanent redirect. By doing so, the traffic of your old page URL will be transferred to the new one.
We can add 301 redirect by using some plugins and editing the .htaccess file. We’ll cover all these methods in today’s tutorial.
1- RankMath SEO
One of the most simple way to manage and create 301 redirects is by using a plugin named RankMath.
This is a plugin which we can use for doing all the on-page SEO of our site and it can manage and create 301 redirects very easily.
It also allows you to create other redirects and maintenance code like
- 302 Temporary Move
- 307 Temporary Redirect
- 410 Content Deleted
- 451 Content Unavailable for Legal Reasons
One thing that I like the most about this plugin is that it allows you to add all the above mentioned redirects in it’s free version also.
However, Pro version allows you to dive deep into the SEO metrics of your site. So, if you are looking for a plugin which can mange redirects and also the On-Page SEO of your site then you should definately go with the Pro version of RankMath SEO.
To redirect a page in WordPress using RankMath, you first need to install and activate RankMath Plugin. Check out my guide on Installing WordPress Plugins for more detaills.
Once the plugin is installed and active, you will see the setup wizard having a message of connecting your RankMath account. Create and connect your account and follow the setup wizard.
Note: Remember to enable the redirects and 404 monitors in the setup Wizard to view all the 404’s on your site and also to create redirections.
Now we are ready to create redirection, simply go to RankMath » Redirections and click on the Add button to add a redirection. You will also see all the redirections here, that you will create. You can easily deactivate or delete them, if you want.
Once, you click on the Add button, you will see a interface where you need to add your source URL (Old URL) and the destination URL (New URL). Also, you can select the type of redirection you want to made, as we are focusing on 301 permanent redirect so we’ll choose 301 redirect.
Once you have entered the detials now click on the Add Redirect button to activate this redirect.
Now, when someone will visit the old URL, he’ll be automatically redirected to the new URL.
Redirections
The 2nd plugin to create and manage redirections is using a plugin named Redirection.
First, you need to install and activate this plugin. Check out my guide on Installing WordPress Plugins for more detaills.
Once the plugin is install and activa, now go to the Tools » Redirection and start the configuration by clickin on the Start Configuration button and follow the configuration process.
Once the setup is complete now go to Tools » Redirection » Redirect to add a new redirection.
Now, add your source URL (old URL) in the source URL field and desitination URL (New URL) in the Target URL field and click on the Add Redirect button to activate the redirect.
You can click on the Gear icon as shown in the above picture, to view more settings where you can change the redirection type of you want.
301 Redirects
301 Redirects is another plugin that can permanently redirect a page or URL in WordPress easily.
To start redirecting, you’ll hvae to install and activate this plugin. Check out my guide on Installing WordPress Plugins for more detaills.
After that, simply go to Settings » 301 Redirects and fill up the Request field with your old URL and the Destination field with your new URL. Now click on the Add New button.
Page Links To
Let’s say you want to keep a post or a page but want to redirect your users to another URL. You can do it simply by using Page Links To plugin.
This simple plugin adds a meta box to your WordPress editor where you can set the address of the new location to which your users should be directed.
To set up 301 redirects using a WordPress Plugin is very simple and easy but it does have some minor performance drawbacks like your site may take a few microseconds longer to load depending on your WordPress hosting provider.
If you want to speed up your redirection, you can use the coding approach and the.htaccess file.
Redirect a Page in WordPress by Editing htaccess file
By editing the.htaccess web server configuration file, WordPress users can easily set up 301 redirects.
Please note that even a minor error in your.htaccess code can turn your WordPress site unavailable and cause an Internal Server Error to appear.
That’s why, before making any changes, you should make a backup of your.htaccess file.
You can edit your .htaccess files even by using RankMath SEO plugin OR you can directly edit the file from your cpanel.
If you are a beginner, I’ll recommend you to edit the file using RankMath.
So to edit the.htaccess file, go to your WordPress dashboard and click on the RankMath » General Settings and click on the Edit .htaccess tab. you will see the content in your .htaccess file.
You can simply put the redirect code you like, at the bottom of the page.
Here’s a simple redirect that redirect a visitor from an old post to a new post.
RewriteEngine On
Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/
Now click on the Save Changes button to save your changes. After that, the RankMath plugin will update your .htaccess file.
Editing .htaccess file Through Cpanel
If your hosting provides provides you the cpanel, then you can simply login to your cpanel and go to the File Manager.
From here you can view the .htaccess file in the your site’s folder where WordPress has been installed.
First take a backup of the file by right clicking on it and then click on the download button to download the copy.
Now that you have a backup of your htaccess file, right click on the file and then click on the Edit button to edit the file.
Now, do the same as we did in the previous method. Simply add the redirect code at the bottom of the file.
RewriteEngine On
Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/
Now click on the Save Changes button to save your changes.
Editing .htaccess using FTP client server
If your hosting plan doesn’t provide you the cpanel access then you can edit the .htaccess file by connecting to your site using an FTP client server.
Once you are connected with your site Now, You can set up any redirects directly in your WordPress .htaccess file.
The.htaccess file is located in the root directory of your WordPress site.
If your .htaccess file isn’t visible, you’ll need to instruct your FTP client to show hidden files.
Any plain text editor, such as Notepad, can be used to edit the.htaccess file.
Here’s a simple redirect that attempts to redirect a visitor from 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 to your.htaccess file, preferably at the end.
Keep in mind to save your changes and re-upload the .htaccess file to the server. After that, you should test your redirect to ensure it is working as expected.
I hope that thiis guide to redirect a page in WordPress helped you to setup redirects in your site. You can also view my guide on How to start a blog and Best WordPress Themes.
If you liked it please subscribe to my YouTube Channel for WordPress video tutorials. You can also find me on Twitter, Facebook, and Instagram.