When changing domains or redesigning URLs, it is important to set redirects correctly and sensibly with regard to onpage search engine optimization. If SEO know-how is lacking, numerous internal links on large websites suddenly go nowhere and generate crawling errors - significant losses in search engine visibility are the result. Before relaunches and directory restructurings, it is therefore necessary to plan exactly which redirects are set when, how and where.
HTTP redirects can be accomplished with the status code 301 or 302. Since the server response 302 only signals a temporary redirect, SEOs work far more frequently with the code 301. Here, the old URL is not retained, but is permanently invalidated and replaced by a new address. Thus, the new URL takes over the linkjuice of the old one and the value of the backlinks is preserved. The prerequisite is the correct technical implementation of 301 forwarding.
To redirect a client or the Googlebot to the new resource when calling a URL that no longer exists, specify the new address as an absolute URL in the .htaccess file with the following code:
Redirect 301 /verzeichnis/weiterzuleitendes-dokument.html https://www.beispieldomain.de/neues-dokument.html
To redirect a whole domain for example to avoid duplicate content, this code can be used:
Setting the "RewriteEngine on" command before the individual redirects is necessary to turn on the Apache "mod-rewrite" module. Otherwise, the URLs on the Linux server cannot be manipulated. The directive "RewriteCond" defines when the redirection should be done by RewriteRule.
Alternatively, the 301 redirect can be included as a header in a PHP file. This code must then be written in the old file to redirect clients to the new php resource:
header("HTTP/1.1 301 Moved Permanently");
301 redirects should always be content accurate. That is, the new destination must be a true replacement for the old one. Redirects to the home page are just as unfavorable as stringing together several redirects.
When changing domains and URL structures, it is essential to plan redirects well so that a number of links do not suddenly go nowhere. It is not always possible to apply redirect rules for 301 and 302 status codes. With large e-commerce platforms that use session IDs, there can be problems. Only careful mapping of redirects will help here. How a successful SEO migration strategy can look like in these cases is shown by the blog of builtvisible in the post Mapping Redirects for SEO-friendly Site Migrations based on a domain move.
As is often the case, the first step is to carefully plan the redirects. A site crawl with a tool such as Screaming Frog first records the complete page architecture. The data obtained via standard export is consolidated in Excel together with the URL parameters from the Google Search Console and the robots.txt file and can now be analyzed with regard to the page types, URL parameters, file extensions as well as canonicals and directories. The SEO then determines which pages are forwarded with redirect rules and which are mapped.
As a basis for the mapping, xml sitemaps can be used wonderfully, after all, all indexed pages of a website are already listed here. The sitemap index shows which files are available in detail. A URL crawl with Screaming Frog serves as another data source and identifies status code errors, redirects, meta robots tags, canonical tags and URLs blocked by robots.txt. From Google Analytics, landing pages with organic traffic can now be pulled. With the table add-on for Google Analytics, more than 5,000 rows can be exported.
The clean sitemap and the Analytics report are added to the Excel Workbook and the data is matched via SVERWEIS. Finally, new URLs from Screaming Frog are added. For large websites, make sure that the link juice of all URLs is passed on. A backlink check, for example with Majestic, is therefore a must. The list of top URLs is again matched with SVERWEIS with the Excel Workbook. Finally, the complete procedure has to be repeated for the domain to be migrated to.
To start the actual mapping process, we copy the two clean URL lists for the domains into a new workbook in two sheets. H1 tags are best for mapping because you get results quickly. The H1 is moved to the first column in the target domain's sheet, and a new column is created next to the URLs in the other sheet. With the formula =SVERWEIS([@H1],Sheet!$1:$1048576,2,FALSE) the resourceful SEO now matches the URLs to be redirected. If the H1s do not work, the title tags and URL stems can also be used. The domain name, IDs or file extensions from URLs in e-commerce platforms are filtered out with the formula =LEFT(A1,FIND("/",A1,9)-1). Using the "Text in Columns" command, we split the stems after each slash in the URL so that the text can be isolated. We enter the results for both domains in a new column and match the whole thing again. If none of the methods described so far work for certain URLs, they can also be found via Google's site search.
Finally, a check whether all URLs to which redirects are made issue the HTTP status code 200 ensures the success of the redirect mapping.
You can learn more about redirects in the context of Google Search at Google Search Central. The URL Rewriting Guide from apache.org can also be helpful for implementation.