Share this post on:

Summary

There are occasions when an old directory of web pages or posts no longer exists. If they have been moved to a different location, it is possible to redirect site visitors to the new location. This page describes how to redirect a site visitor from one directory to another.

Background

Many years ago, it was common to install WordPress to a directory on an existing website as the method for having a blog function. It was similar to installing a MySQL forum function to a website. For the site visitor, it seemed to seamlessly be all part of a single website domain. With WordPress, it would be common for the blog to have a slightly different layout and appearance from the main site design. Today, WordPress is used as the main mechanism for site design as well as the blog function. So, it is no longer common to have WordPress installed to a directory.

Solution

Follow the steps outlined below to provide directory redirection. In this example, posts for a site that was previously configured with WordPress installed in a /wp/ directory will be redirected.

TASK #1 — Install Redirection Plugin

Install the Redirection Plugin as follows:

  1. From your WordPress Dashboard click on Plug-ins and click on the “Add New Plugin” button at the top of the page.
  2. In the “Search Plugins” box, type Redirection and press enter.
  3. Click on the “Install Now” button.
  4. Click the “Activate” button when it appears where the Install Now button had been.

TASK #2 — Setup Redirection Plugin

Go through the guided setup to get the initial installation of the plugin.

  1. Click the Start Setup button.
  2. For Basic Setup it is probably okay to leave the option boxes unchecked.
  3. Click the Finish Setup button.
  4. After clicking Finish Setup, you should end up on the “Setting up Redirection” page.
  5. Click the Continue button when the process is complete.
  6. When you see the “Installation Complete” message, click the “Ready to Begin” button.

As indicated on the last page of the setup process, some WordPress configurations will not work with the Redirection plugin.

TASK #3 — Configure Redirection

You will find the Redirection plugin settings page from your WordPress Dashboard under Tools > Redirection. Follow these steps to setup a directory redirection.

  1. Click the “Add New” button.
  2. Click the gear icon to view advanced options.
  3. Following the example below, you can configure your own directory redirection. Further instructions are below the example image.

From top to bottom, here are some considerations and comments:

  1. Enter the Source URL based on your need. In this example, WordPress was originally installed to a directory /wp/ and after being moved to a new hosting platform is no longer in a /wp/ directory. This redirection example is specifically for the posts that were put in the /wp/docs/ folder which are now in the /docs/ folder. So, for the Source URL in this example, the entry is /wp/docs/(.*)
    • NOTE: The text (.*) is to capture whatever URL information is provided by the site visitor, such as a Post URL. That information will be used later.
  2. The Ignore Case option is retained. The Ignore Slash option is removed (by clicking the ‘x’ next to it). The Regex option is added by clicking the downward ‘v’ for the dropdown menu and putting a checkmark next to Regex.
  3. The Title is “Old WP Folder” but you can provide whatever name you want that best describes your redirection.
  4. For the “When matched” setting use “Redirect to URL” and choose the 301 – Moved Permanently to instruct search engines to update their records with the new address.
  5. For Target URL, enter your entire website address with the destination directory and the variable that will provide the remaining URL from what the website visitor had requested: /$1
  6. The “Group” and position options let you organize your redirection entries if you plan to have many of them.

Reference and Resources

You may need to run some tests for your own application. The following resources may help guide you with more advanced configurations.

  • Redirection Plugin Page — on the WordPress website [View]
  • Redirection Plugin Website [View]
  • Redirection Plugin Website – Page Describing Directory Redirection – Using Regular Expressions [View]