Best way to move site from subdomain to root through cPanel?
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, subdomain, , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :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?
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.
Comments
Post a Comment