Sometimes we might go from a site located in a folder off the root of a site to a subdomain or site of its own in a standalone environment.
Why would we want to do this?
There are some advantages for separating out your sub-sites into separate sites:
Security: With sites separated out, each is actually more secure. That stems from the fact that should something become compromised (when all the information is in a single site), everything becomes compromised. From a security standpoint, if bad actors get into a site they are usually only in the one site. The risk of bad actors get into your other sites increases exponentially if your administrative accesses are the same. Since we can save our passwords in our browsers so easily, there is no reason to use the same password over multiple sites. That’s asking for trouble.
Organization: Material can be organized and focused better for each of your sites. I have spoken for many years about the concept of SEO dilution. When a website focuses precisely on a specific product or idea it is more apt to be seen by search engines as an authority on that product or idea. This is one of the building blocks of search engine optimization.
Speed: Separated sites are able to operate faster. Websites are allocated machine resources by the operating systems of the servers upon which they reside. Each separate site has more resources than if they are all together in a single site space. There is always a lot of hype about speed on the web. Yes, speed is important in that no one wants to wait a long time when viewing a website. Running our own web servers at CharlesWorks as well as using external web servers have shown us that what rules is the content of the site.
The Syntax for Redirections
Redirecting website content mostly becomes a problem when a site has had its pages listed in search engines. For instance, in the solutions listed below there was a primary website that branched off into several other independent sites based upon the city. In this example, one of the “city” sites was being moved from:
or, it could have been moved to:
The following code example will solve this when using John Godley’s Redirection Plugin in the Regex mode. Obviously, make sure the Redirection plugin is installed and active on your website. Note the following:
Redirection code placement: This redirection code must be placed in the original site’s URL
Folder cannot exist: In order to work, the folder the site was in must be deleted or a 403 error will occur
It’s pretty easy to get this working.
You will have to be logged in with administrative access in the WordPress dashboard. Navigate to:
Tools > Redirection
Then click on the Add New button after Redirections in the upper left
Now just modify the original boxes (Source URL, choose Regex and Ignore Case, and Target URL) to reflect the correct original URL site descriptor and target URL:
or, if this is the case:
The “(.*)” coupled with the corresponding “/$1” in the above code retains the remainder of the URL so the redirection to specific pages that search engines have retained will still get site visitors to the correct newly addressed information.
This example is similar, and fixes “feeds” that were accessed at the original URL. In this example the slug names were changed to reflect the new site the posts were now in:
As with any changes you make, be sure to test them! Testing is done best with a separate browser that you haven’t accessed the site you are dealing with recently. You may also have to clear your computer’s cache.