How To Redirect A URL In WordPress, Cpanel And Htaccess File

How To Redirect A URL In WordPress, Cpanel And Htaccess File

There are plenty of ways of creating redirects for URLs but before I get into the different ways that I think are the easiest, let me explain why it’s essential to set up redirects to begin with.

Why It’s Essential To Set Up Redirects?

A redirect is a webpage or URL that points to another URL. That may not sound like it matters too much but having a visitor land on your dreaded 404 – Page Not Found can make or break if they purchase your product, subscribe to your newsletter or even consider returning back to your site at all!

Let’s break down the different reasons why it’s essential to set up a redirect.

You’ll Lose Out On A Potential Sale Or Subscriber – As I just mentioned, a visitor landing on a 404 page can make or break if they purchase a product, subscribe to your newsletter or even return at all. More often than not, it’s the latter of the two.

No One Likes A “404 – Page Not Found” – Nothing is worse than landing on a webpage for something you’re desperately looking for and it not being there.

Okay, maybe there are plenty of things worse but I hate the feeling of expectations not being fulfilled. I’m sure I’m not the only one!

The chances that visitor decides to look through the rest of your site after landing on a 404 page is pretty slim.

Your Site Will Look Bad – Okay, if you have one page that leads to a 404 page, it happens.  But if most of your indexed pages or linked posts lead to it, it doesn’t make you or your site look good at all.

When Should You Set Up Redirects?

Any time you can so people don’t end up landing on your 404 page. Some instances that occurred in my experience include, but not limited to:

  • If you transferred from a Blogger blog to a WordPress blog. (Blogger URL’s typically look like datmoney.com/this-is-your-url.html but WordPress URLs typically do not have “.html” at the end.)
  • Whenever you delete an indexed or linked post.
  • If you change the permalink of an indexed or linked post.

There are plenty of other instances in which you should set up redirects but those are just a few I could think of that I’ve been through.

Different Ways On How To Redirect A URL

Creating A Redirect URL In .htaccess File

You’ll want to locate where your .htaccess file (this is used to check for information on how to handle errors, security, redirects) in your root directory. If you’re using HostGator or any hosting that uses cPanel, it’ll be under “File Manager” then the “public_html” folder.

You’ll have to make sure you show hidden files (dotfiles) to see the .htaccess file. To do so, simply click on the “Settings” and check the box “Show Hidden Files” as seen below:

DM htaccess file

Once you find the file, click on “edit” and add the line:

redirect 301 /oldURL.com http://www.newURLthatyouwanttoredirectto.com

Save the file.

Make sure to check to see if the redirect works! To do this, simply open up a new private browser (make sure it’s private so it’s not cached by your computer) and type in the old URL.

Creating A Redirect URL In cPanel

If you don’t feel comfortable editing files like the .htaccess file and your hosting has a cPanel interface, there is an option to redirect URLs. Under “Domains” click on “Redirects” then add the old URL in the appropriate field then the new URL in the “Redirects To” field as seen below:

cPanel Redirect

Click “Add”. This writes all the information to the .htaccess file, exactly like the previous option.

Creating A Redirect URL In WordPress

If you run a WordPress website, the easiest way is to install a redirect plugin. The one that I use is called “Redirection”. Simply install the plugin and tweak your settings.

To create a new redirect, simply go to the “Redirections” tab and enter the old URL into the “Source URL” and enter the new URL where you want to redirect your visitors into the “Target URL” as shown below:

WP Redirect

I really like this plugin, not only because it makes everything so easy, but it also helps track things such as how many times your redirects have redirected your visitors and all the old URL’s that lead to your “404 – Page Not Found” page.

If you already have a list of redirects from an existing .htaccess file or a CSV file, you can upload it under the “Options” tab.

I hope this helps. Let me know if you have any questions!

Share