Drop this into the .htaccess file of the old site (adjust the domain to the actual one):
RewriteEngine On RewriteRule ^(.*)$ http://example.com/blogs/string/$1 [R=301]
This will take this part of the url on the old site:
year/month/dd/string-pulled-from-title
and redirect it to a new site in a new place:
blogs/string/year/month/dd/string-pulled-from-title
Alternatively, if you want something a little more variable, for example, without having to configure the fix for each .htaccess , instead indicate this in the file for each subdomain:
RewriteEngine On RewriteCond %{HTTP_HOST} ^(.*).example.com RewriteRule ^(.*)$ http://example.com/blogs/%1/$1 [R=301,L]
If you are redirected to the same domain and enable www , configure the rewrite rules as follows:
RewriteEngine On RewriteCond %{HTTP_HOST} ^(.*).example.com RewriteCond %{HTTP_HOST} !^www.example.com [NC] RewriteRule ^(.*)$ http://example.com/blogs/%1/$1 [R=301,L]
Pay attention to the second RewriteCond , which checks that the requested URL does not have a leading www , which can lead to endless redirection if the target URL itself includes www and would try to redirect this subdomain as well.
source share