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 web pages.
Here’s a brief guide.
How to Add a Redirect Rule
Adding redirect rules from your 10Web dashboard is easy.
Login to your dashboard and click Manage on the website you want to add a redirect. Under Hosting Services, click on Redirects. Click on Add A Redirect to get started.
Under Status, you will see two options:
- 301 is used for the links that have moved permanently
- 302 is used 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 - Choose the domain
- Redirect from - the old link
- Redirect to - the new link
It’ll all make more sense when we go through some examples.
Regex
A regex, short for regular expression, is a sequence of characters that define a search pattern. Since the 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.
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.
The 10Web redirect tool has a few general principles:
- Add specific redirects before you add 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 the basics, let’s apply them to particular examples.
Including https://yourdomain.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://yourdomain.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://yourrdomain.com/archive/file-one and https://yourdomain.com/archive/file-number-one:
^archive/file(-number)?-one
Redirecting www Traffic to Non-www
We’re used to writing in links that start with non-www and www and getting to the same page, that learning how to set up that redirect rule is paramount.
Redirecting www.yourdomain.com to https://yourdomain.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.
You will see a pop up window asking you to upload the CSV file (for example, saved from Microsoft Excel or Notepad).
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.
Save your file as CSV and open it with Notepad to check if the redirect data is in the right format before the bulk import.
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 in that particular interface. As long as the data format is right, it should work on the 10Web dashboard like a charm.
Originally published at https://10web.io/blog/how-to-set-up-redirects-on-your-wordpress-site/ on November 8, 2018.
Comments
0 comments
Please sign in to leave a comment.