Redirect original community.example.com
posts to example.com
You'll still need to keep the subdomain alive in order to redirect any requests (otherwise it simply won't resolve). This is just a redirect everything. In either the .htaccess file at community.example.com
or the main .htaccess file at example.com
(or your server config) you can do something like the following at the top of your script (before any WordPress directives):
RewriteEngine On
RewriteCond %{HTTP_HOST} =community.example.com [NC]
RewriteCond ^/?(.*) http://example.com/$1 [R=302,L]
Change the 302
(temporary) to 301
(permanent) when you are sure it's working OK.
Redirect original example.com
posts to apps.example.com
This is more tricky. You obviously can't redirect everything, because you have a new site hosted here (which you are redirecting to). And you can't do nothing, since that would be SEO suicide - assuming SEO is a priority. (Moving sites / changing domains is always going to suffer some SEO impact, but that can't be helped if the change is required.)
If you only had a limited number of pages at the original site, or there was some unique pattern to these URLs that differentiated them from the new (community
) site then you could set up a bunch of redirects in the Apache config (or .htaccess file). However, with "80,000 pages" and nothing to differentiate from the new URLs, this is not possible.
What you can do is issue a redirect in your (WordPress) custom 404 document. Either by looking up the requested URL in a database (preferable), to see whether you should redirect. Or, simply redirect everything that would otherwise trigger a 404. The "problem" with redirecting everything that would ordinarily 404 is that any 404 will be seen as a 404 at apps.example.com
and not example.com
.
For example, to redirect everything using PHP in your custom 404 at example.com
, something like:
<?php
header('Location: http://apps.example.com'.$_SERVER['REQUEST'],true,302);
Again, change 302
to 301
when you are sure it's working OK.
example.com
? Is there a unique pattern to these URLs, that is different to the new URLs (ie. originally oncommunity
)? Do you have access to the server config / VirtualHost?