Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Stephen Ostermiller Jun 5 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 Jun 5 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]
</IfModule>

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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