How to 301 redirect an old domain to a new domain’s subfolder

I used to have one blog in English and one in Spanish on similar topics, with different domain names. At some point I decided to consolidate and create a bilingual blog. I wanted to create a subfolder in the domain I wanted to keep (domain A), and redirect the old domain (domain B, the one I was letting go of) into that subfolder in domain A so I did not lose my SEO.

Surprisingly, I could not find any clear tutorial on how to do this so I started grabbing pieces of information here and there and testing until I found a solution that I would like to share with you.

As always, make sure your site is backed up:

  1. For redirects you need to go to your FTP server
  2. You will have to modify your .htaccess with Rewrite mode.
  3. You need a 301 redirect. 301 are permanent redirects. These are the ones you need for SEO
  4. Your permalinks need to follow the same structure in both domains. This is important so the urls in both domain mirror each other. The redirect will only change the root domain part in your url: will become
  5. You will not unpublish your old site. At least until you are sure that there are no links in the web pointing at the old domain. Which means never.
  6. Import your content before redirecting. Make sure both your domain B and subfolder in domain A domains have the same content, and everything looks good in the domain A’s subfolder. Then do the redirect

The way a redirect works is by never allowing the user to see the old domain again. Although it is still there because old links will be pointing at it what happens is that everytime some user requests it, it will change in the browser to the new domain immediately.

There are many ways to use a redirect: redirecting pieces of content inside your domain, redirecting from your domain A to a subfolder in that same domain or viceversa. Or from a different domain to a new domain, wether it is the root domain ( or a subfolder (

Depending on what you need, the code will change slightly. Here you can see different codes for different cases. My case does not seem to be very common because none of the above codes were working.

I had a whole domain (Periodista Hispano) that I wanted to permanently redirect (301) to a subfolder in my domain Onlinista, thus converting Periodista Hispano into a Spanish version of Onlinista (I wanted a bilingual blog). Then I realized that those redirect codes provided were meant to work inside a single domain (domain 1). I remembered seeing this somewhere so I tried substituting some info (index.htm) for $2, which I believe tells the server it needs to go outside of the domain and it worked!

In the following code you will see “WordPress” mentioned but you do not have to include this in your .htaccess file if you don’t work with WordPress (these are the first and last lines of the file, which you do not need to modify, anyway). Copy from RewriteEngineOn to the last RewriteRule. $1 and $2 tell the servers that you are joggling 2 different domains.

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress

When I created my subfolder I imported my old blog to the new domain, and then did the redirect, making sure that whoever landed in the old blog was redirected to the new one (to test, delete your cookies/history).

When you redirect a whole domain which content you have previously imported you do not need to redirect every single piece of content in that domain. The above code takes care of everything. But remember that you need to import all your content to the new domain before you redirect and keep your urls without modifying them (keep your permalink structure). Readers will be taken from the old domain to the exact same content you have made ready for them in your new domain.

I hope it works for you!

Photo credit: mhaithaca via photopin cc

Clarisse Céspedes

Journalist and Content Strategist. SEO, sponsorships and video. Follow me on Facebook and @ClarisseCespede.

One thought on “How to 301 redirect an old domain to a new domain’s subfolder”

Leave a Reply

Your email address will not be published.