I show you step by step how to set up a redirect in WordPress without using a plugin. By adding code to your htaccess file and you can permanently redirect your visitors from an old post URL to a new post URL.
Let’s set up that redirect.
- Before you start, make a backup
- Open your pages in new browser tabs
- How to set up a redirect in WordPress using Filezilla
Before you start, make a backup
In my tutorial, I will show you how to add code to your htaccess file. The htaccess file is important for your website. Adding incorrect code to this file will break your site. Therefore, make a backup of your file before you make any changes. If you do make a mistake and break your site, then you can replace the edited file with the original.
I will show you how to make a copy of your htaccess file using Filezilla. Filezilla is an FTP client that makes editing files easy.
Make a copy of your htaccess file via Filezilla FTP client
Using an FTP client allows you to gain access to your website folders and files without having to go into your hosting Cpanel. I use Filezilla if you would like to read a tutorial on how to download and install Filezilla, check out my Filezilla post.
Once you connect to your website, you can see the list of folders and files for your site. Look for the ‘Public_html’ folder.
Double -click on this folder to open it, then you will see your htaccess file.
To download this file to your computer and make a copy, right-click and select download.
Open your pages in new browser tabs
I recommend you open the post or page that you want to redirect from and also the post you want to redirect to in new browser tabs. You do this so that you can copy and paste the URL of each post.
Here are my tutorial posts that I am going to redirect.
I am going to add a redirect in WordPress from this post.
The redirect will take people to this post.
How to set up a redirect in WordPress using Filezilla
To set up a redirect in WordPress, we need to edit our htaccess file. I am going to use Filezilla to edit my file.
This is an example of the code we need to add to this file –
RewriteEngine On Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/
I will show you how I need to change this example to fit my blog posts.
The ‘ /a-very-old-post/’ part of this example code after ‘Redirect 301’ is taken from the post you are planning to delete. Here is a screenshot of my post. I need to copy everything in the address bar after ‘.com’. Like this.
The ‘ http://yoursite.com/a-very-new-post/ ‘ part of the example code is taken from the post you want your visitors to be redirected to. Here is a screenshot of my new post. You copy everything from the address bar. Like this.
The code I need for my redirect looks like this.
- RewriteEngine On
- Redirect 301 /uncategorized/old-post/ https://example.newblogr.com/uncategorized/new-post/
Now we open our htaccess file and place this code. To edit this file in Filezilla, right-click, and select ‘View/Edit’.
If you haven’t downloaded this file to your computer yet, do that before you add any code.
Now we can edit this file. I can see from this opened file that I have the ‘RewriteEngine On’ code already. So I will copy and paste my code without that.
This is my htaccess file before I added the code.
Here is my htaccess file after I added the code.
To save this file, open ‘File’ and select ‘Save’.
After you select ‘Save’ the window will stay open. Close the window, then you will see this message.
Select ‘Yes’ to confirm your changes. Now your redirect in WordPress is active.
Now your redirect is active
Here is my old post. I am going to reload the page, if my redirect is working, I will see my new post after the reload.
Here is the new post. My redirect is working.
If you are planning to delete posts or pages from your website, I recommend you set up redirects for those posts. The reason for this is that there could be external links to those posts.
If a visitor clicks on a link that takes them to a deleted post, they will get a ‘Page not found’ message. Not a good experience for them.
If Goole has indexed your deleted post, they will continue to send visitors to that post. Once Google detects that the post has been removed, they will send you an error message in your Google search console dashboard. This is not good for your SEO.
Setting up redirects is easy if you use Filezilla. Make sure you take care when editing the htaccess file. It is important for your site, make a mistake with this file and you will break your site. As I recommend at the start of my post, make a copy of the file before you make any changes.
How do you set up redirects for your blog?
Do you create redirects for your deleted posts and pages?
If you have any questions, please leave them in the comments box below. I check comments at least once a day.
I look forward to reading your comments.