How to Set Up Redirects on Your WordPress Site

Redirections banner

Ever been annoyed by an infamous Error 404 Not Found page? Setting up redirects on your website will let you redirect any traffic your broken links get to functional webpages.

Here’s a brief guide to everything redirect.

How to add a redirect rule

Adding redirect rules from your 10Web dashboard is the easiest thing. If you don’t have an account yet, by the way, it is super easy to register and use.

Once you get a 10Web-hosted site, login to your dashboard and click “Manage website,” click the “Redirects” section under the Hosting Services tab on the left:


Here you’ll see you can see two options under Status: 301 and 302. These signify the different types of redirects.

301 is used for the links that have moved permanently;
302 is for the links that move temporarily.

Most of the time you’ll likely use 301 redirects: links usually move permanently. These redirects transfer about 95% of link authority.

The rest of the menu is pretty intuitive: domains is where you pick the domain, redirect from is for the old link, and redirect to is the new link. It’ll all make more sense when we go through some examples.

Regex use

A regex, short for regular expression, “is a sequence of characters that defines a search pattern.” Since 10Web redirect tool uses regex, you should know basic regex to use it in “redirect from” and capture group references and some variables in “redirect to.”

Here’s some regex 101:

^A – Match any string that begins with A.
A$ – Match any string that ends with A.
AB? – Match A or AB, that is B is optional.
AB* – Match A or AB or ABB or ABBB etc., meaning B can be absent or repeated however many times.
AB+ – Match AB or ABB or ABBB etc., meaning B can be repeated however many times.
A.B – Match a string that goes A, then any character, then B.
(?i) – Activates case insensitivity so, for example, /post and /Post match the same.
A|B – Match A or B.
\ – Escape character.
.* – Logically, this will match anything.

You can use this site to test out your regex and look stuff up from this cheatsheet.

Our redirect tool has a few general principles:

  • Better add specific redirects before you do general ones as the tool reads them in the order of addition.
  • It is by default case sensitive (Post and post are not the same) and has linebreak characters, space, “, and # as restricted characters.
  • It doesn’t redirect by arguments.

Regex examples

Now that we’ve glossed over regex basics, let’s apply them to particular examples.

Including https://userdomain.com/archive page:

^/archive

Note that we use “^” to avoid the confusion with links that end in /archive but don’t begin by it, such as /blog/archive for example.

Making sure /archive and /archive/ are both redirected to newarchive:

^/archive/?


Making it case insensitive:

(?i)^/archive/?

Redirecting the file https://userdomain.com/archive.php:

^/archive\.php

Redirecting all PHP files in the archive:

^/archive/.*\.php

If you run into an error such as ERR_TOO_MANY_REDIRECTS it means you’ve probably caused a redirect loop: the “redirect from” and “redirect to” read the same. For example, if you have

Redirect from: ^/archive/file Redirect to: ^archive/file-one

It will cause a loop because ^archive/file doesn’t have an end of the string indicated, so ^archive/file-one redirects in a loop. To fix the error, note the end of the string:

Redirect from: ^/archive/file$ Redirect to: ^archive/file-one

Redirecting both https://userdomain.com/archive/file-one and https://userdomain.com/archive/file-number-one:

^archive/file(-number)?-one

Redirecting www traffic to non-www

We’re so used to writing in links that start with non-www and www and getting the same page that learning how to set up that redirect rule is paramount.

Redirecting www.userdomain.com to https://userdomain.com:

Bulk import of redirect rules

Do you want to finally delete your plugin for redirects or have an uber complicated redirect network in a file? Bulk importing is easily done from your 10Web dashboard.

Click “Bulk import” from the Redirects section:

This form asking you to upload the CSV file (for example, saved from Microsoft Excel or Notepad) will pop up:

The file should have a new line for every redirect and the data in this order: Status (301 or 302), domain (“all” or the URL), redirect from, redirect to URL.
In this example we use an Excel file:

We “Save as CSV” and open it with Notepad to check if the redirect data is in the right format:

Since it is, we can bulk import the file!

Exporting redirects

Some of our users’ websites have a huge number of redirects and naturally we want to make it easier to migrate the redirects to a different service or just keep them as a CSV file. It only takes a click on the “Export to CSV” button:


If you want to redirect your exports from some other WordPress plugin or service, you’ll have to look for the Imports/Exports settings’ page on that particular interface. As long as the data format is right, it should work on 10Web dashboard like a charm.

That’s pretty much it with 10Web redirects 101. If you want to perform a more difficult redirect, you can always rely on our customer care. Let us know in the comments if you run into any redirect-related trouble!

You like this article? Spread the word!

Leave a comment

Your email address will not be published. Required fields are marked *

Your email address will never be published or shared. Required fields are marked *

COMMENT*

NAME *

WEBSITE