Content on the Move with HTTP 301
One of our customers, Christina, had a problem. For a certain keyword, her content was not listed by Google. Not at all. And this, although it was specifically optimized for this keyword. What was going on? For days we puzzled with all the SEO specialists of the local WordPress community why Christina’s whole page did not appear once despite optimization on 29 pages (SERPs) for the keyword in question. Underoptimized? Overoptimized? Penalty because of whatever?
After much brooding and discussion it turned out that Christina had deleted about 90 pages of her website due to a restructuring. The Google bot, which regularly crawls websites to index them, had not liked that at all. Apparently the site was delisted on keyword level because of the many, suddenly no longer findable contents, excluded from the SERPs, or algorithmically penaltied on keyword level. More about this can be found here. You have to get to it first.
Christina then set up a 301 redirection for the deleted pages and kindly asked Google to re-index them. Bam! Website on page 4 in the SERPs to the keyword. From then on a proper search engine optimization could take place.
Since it is quite annoying if your own content suddenly no longer appears on Google for the main keyword, you should keep in mind that you should move or delete large amounts of content with a 301 Moved Permanently HTTP header. Also, in order to avoid a penalty for duplicate content under certain circumstances.
You can set up 301 redirects either via server configuration, i.e. a redirect entry in the .htaccess for Apache servers, or a header statement via PHP. We currently had the requirement to redirect individual post URIs to new content without destroying Google rankings. We solved this by placing the following code in the header where the old content is displayed.
This allowed us to selectively pick individual pages from the accesses and redirect them to pages of the new website without creating SEO chaos. The process is invaluable if the link structure changes during a relaunch, but you still want to benefit from the ranking of the old content, which you may have earned over decades.
And since we recently had exactly this requirement for a TYPO3 to WordPress relaunch on the same domain, here comes the corresponding procedure for the functions.php of the WordPress Child theme.
The redirect only takes place if you are not logged into WordPress. This is convenient if someone wants to create and check content on the source URI later.