I have an old Wordpress blog hosted on a subdomain (sub.mysite.com) with hundreds of posts.

The root domain is actually empty and redirected to the subdomain.

Now I want to move the site from the subdomain to the root domain.

I found some .htaccess examples like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.example.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

This redirection seems to work if I clone or move the subdomain site into the root domain but, Is there an easier way? I mean, just like when you redirect from www. to non-www. and you only have one site installation. The site would be kept installed on subdomain folder but it would be accessed from root domain, is it possible?

  • How did you set up the subdomain? To answer this question we'd need your virtual host configuration file or how it looks in cPanel. Commented Jun 5, 2014 at 10:04
  • In cPanel I just created de subdomain and installed Wordpress in it. The root index.php just has a 301 redirect to the subdomain.
    – Mbbc
    Commented Jun 5, 2014 at 10:08

1 Answer 1


If you have mod_proxy available, you could proxy all requests forward to the subdomain through your .htaccess file with the [P] flag.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ http://sub.example.com/$1 [P]

Maybe not the best way (the best way would be to move all the files and reset any links properly), but certainly the easiest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.