How to Redirect a Single WordPress Website Page to Another Page
Redirecting one of your WordPress pages is fairly easy and straightforward—you just need to install a redirect plugin and then follow these steps:
- Log into the WordPress backend;
- Go to Plugins → “Add new”;
- On the top right hand side, search for “redirection”;
- You will see a number of options show up – click “Install” on the one by John Godley;
- Click “Activate”;
- Go to “Tools” in the left hand side menu of your WordPress Admin panel;
- Click on “Redirection”;
- Click on “Add new”;
- Enter your Source URL;
- This is the URL of the page where you want to implement your redirect.
- In my case, this was /its-my-old-page (the page I needed to redirect.)
Important: Use what’s called a “regular expression”, which you will append at the end of the source URL and it will redirect your users even if they are being sent from a link containing a UTM parameter, to your new URL. To be able to use it, first enable “Regex” by ticking the box next to the Source URL field.
The expression you need to add to the end of your source URL is this: (?!\/.*\/)((\/?)$|.*.*=.*) In my case, the final source URL looked liked this: /its-my-old-page(?!\/.*\/)((\/?)$|.*.*=.*) Quick note: if your URL has a trailing slash (i.e. it ends in a forward slash because, for example, it indicates a directory on your website), you need to remove that slash and add the regular expression right after the last word in your URL.
- Enter your target URL;
- This is the URL of the page you want to redirect to.
- In my case, this was /its-my-new-page.
- Add any group you want: “Redirection” or “Modified Posts”. This doesn’t really have an impact on the redirect, it’s just a way for you to classify them.
- (Optional) Click the little gear button next to “Close” and use the “Title” field to enter a description for your team;
- E.g. “Christmas 2020 seasonal redirect cleanup project”.
- Select your “When matched” option:
- Redirect to a URL (the default option, which I used and recommend you to use as well in this type of situations);
- Redirect to a random post;
- Error (404);
- Do nothing.
- Choose the HTTP code you want to use:
- 301 – Moved Permanently (the default option, which I used and recommend you to use as well in this type of situations);
- 302 – Found;
- 307 – Temporary Redirect;
- 308 – Permanent Redirect.
- Click “Add” button.
Verify Your 301 Redirect
Now that you have added your 301 redirect, you need to make sure it’s working:
- Go to your source URL (e.g. in my case, http://asiteaboutemojis.com/its-my-old-page).
- Hit the refresh button.
- If it’s redirecting to your new URL (e.g. in my case, http:// asiteaboutmojis/its-my-new-page), everything is in order.
- If you have a cache WordPress plugin installed, you might need to refresh the cache and test again.
- If you want to make edits, you can go to “Tools” → “Redirection”, then click “Edit” under the redirect you want to change.
How to Redirect an Entire Subpath to a Specific Page
If you are replacing an entire subpath on your website, you should use a different method. For instance, if “A Site about Emojis” was selling colored emojis (red, green, blue, etc.), and one day I decided that I don’t want to sell blue emojis anymore, I would have to redirect that entire subpath. In this example, I’ll show you how we can implement a single redirect for all of my product pages for blue emojis:
So, here’s how to do this:
- Go to “Tools” → “Redirection”;
- Click “Add new”;
- Enter your source URL (e.g. /blue-emojis).
- Keep in mind, you should only add the subpath URL here.
- So, for example, If the blue emojis I want to redirect would be sold at URLs /blue-emojis/product-1 and /blue-emojis/product-2, my source URL would be /blue-emojis.
- Add a forward slash and then the regular expression (.*) after that. So, my source URL would look like this: /blue-emojis/(.*).
- Enable “Regex”(regular expression).
- (Optional) Click the little gear button and add a title for this. In my case, this would be “Sold out of blue emojis last year”.
- Leave the default options checked, same as I did with redirecting a single page;
- Add your target URL (e.g. /red-emojis)
- Click “Add Redirect”.
Verify your 301 redirect
- Open an incognito window.
- Enter an old page/ old URL that existed on the subpath you have just created a redirect for (http://asiteaboutemojis.com/blue-emojis/page-1, for example). If it redirects to your new page (http://asiteaboutemojis.com/red-emojis/red-emojis), you are good to go.
- Repeat the same process with at least a few pages on the subpath you have just redirected.
- If you have a cache plugin installed, you might need to refresh the cache and test again.
How to Move to a New URL Structure
There are also cases when you might want to migrate all the URLs in a subpath to a new URL structure. For example, if you own an agency and you have a new client whose URL structure is plain and simply badly built, you might have to migrate all the URLs in a subpath to another one, while making sure the original URLs still work when users try to access them. In our example, we will move all of the pages in a specific subfolder:
And match them to their corresponding web page on a new subfolder:
- /business-related/page-1 → /enterprise/page-1
- /business-related/page-2 → /enterprise/page-2
- /business-related/page-3 → /enterprise/page-3
- /business-related/page-n → /enterprise/page-n
With a single redirect. Here’s how you would do that:
- Go to “Tools” → “Redirection”;
- Click “Add New”;
- Enter the source URL, remove the domain from it, and then add the /(.*) regular expression;
- e.g. /business-related/(.*)
- Enable Regex;
- Enter your target URL, remove the domain from it and then add the /$1 regular expression;
Verify your redirection
- Visit one of the URLs that you are trying to redirect. E.g: “http://asiteaboutemojis.com/businessrelated/page-50”
- Check to see if the parent sub-folder (i.e. subpath) has changed according to your redirection. E.g.: “http://asiteaboutemojis.com/enterprise/page-50”
- If it has redirected, you’re good to go!
As a last note, you can always manually check all of your redirects—but I highly recommend you to use a tool that will give you the actual server response on these. I really like Browseo, for example.
That’s it! That’s how you create and verify a 301 redirect on WordPress—be it to redirect a single page to another, to redirect an entire subpath to a single page, or moving to a new URL structure.
Doing this will keep your URL structure clean and organized, and improve your SEO rankings and your user-experience, without putting you at risk of losing traffic on the pages you redirect—so it is extremely important that you do it right.