0
votes

This question is very similar to Redirect subdirectory of old domain to root folder of new domain via htaccess but that one is not a complete answer for me, so here goes:

  • My client has static HTML page site with a Wordpress blog in www.olddomain.com/blog/
  • We just moved her blog (and other content) to Wordpress, now situated as as www.olddomain.com
  • We're keeping the same permalink structure in hopes that olddomain.com/blog/some-post can redirect to olddomain.com/some-post.
  • She also has other 301 redirects in the same .htaccess file; most are domain name redirects to static pages in her old site that she's keeping in parallel with the Wordpress site.
  • From my reading, I need to put the standard Wordpress IfModule statement at the bottom of the htaccess file, which I have done.

What I need are the lines that will redirect any blog posts from the old location to the new location, something like:

RewriteCond %{HTTP_HOST} ^olddomain\.com [NC] [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com [NC] 
RewriteRule ^blog/(.*)$ olddomain.com/$1 [R=301,L] 

Will these work? Where do they need to be in the file if there are other 301 statements for unrelated domains?

Toolie

1

1 Answers

0
votes

You need to do this redirecting of old stuff before you turn Wordpress's SEO stuff loose on it.

RewriteEngine On
RewriteCond %{HTTP_HOST}  ^(www\.)?olddomain\.com [NC]
RewriteRule ^blog/?(.*)$  /$1  [R=301,L]

How many domains are involved? Is it all under this one domain? In that case, you don't need to check the HTTP_HOST and can omit the RewriteCond. R=301 tells search engines to update their indexes (and users to re-bookmark the site).

You've already done the work, but I'll repeat what I always say about moving existing installations: Don't. Put major applications and subsystems in their own directory tree, and either URL rewrite if it's the only application, or put a custom landing page in. The most important gain is that other applications (future) won't have to pass through Wordpress's .htaccess.