Easier way to redirect subdomain pages to new domain
I am running several sites on the same IP address. They are WordPress sites and I understand that any Rewrite commands in .htaccess have to be above the CMS/ (Begin WordPress) commands in .htaccess
"mainsite.com" has a subdomain- "subdomain.mainsite.com"
I have moved everything from "subdomain.mainsite.com" to "newsite.com"
An issue with the move is that files are named differently---
"subdomain.mainsite.com/file1/" are now named "newsite.com/dir1/file1/"
Using Cpanel--I created a redirect for the main directory (then copied and pasted code to the space above CMS section of the file)
"subdomain.mainsite.com" to "newsite.com"--works like a charm
But...
"subdomain.mainsite.com/file1/" does not redirect to "newsite.com/dir1/file1/"
I created in the .htaccess file of "newsite.com" this redirect:
"newsite.com/file1/" to "newsite.com/dir1/file1/" -works like a charm
I can now redirect:
subdomain.mainsite.com/file1/ to "newsite.com/dir1/file1" (but it takes creating the rewrite rules in two places)
Questions:
1) Is there an easier way to do this?
(I personally would not have changed directories of the files like an assistant did--and I think that might have solved the issue--but I am not going to ask him to go back and change all of the work already done)
2) Is there a limitation to the number of directories from a subdomain that can be redirected--
Ex: "mainsite.com/" to "newsite.com/" OK
Ex: "mainsite.com/file1/" to "newsite.com/file1/" OK
Ex: "mainsite.com/file1/ to "newsite.com/dir1/file1/ OK
Ex: "subdomain.mainsite.com/file1/" to "newsite.com/dir1/file1/" BAD
I originally tried to do a wild card redirect for the subdomain, but basically only the home page of the subdomain would go to the home page of the new domain...it was not doing what I needed it to do.
Without further guidance, I was not going to manage the subdomain on my GoDaddy account because I often end up getting 500 errors.
Trying to get a handle on this and learn how .htaccess works in CPanel.
-
Hello, Could you let us know the contents of the existing .htaccess file that's utilized in the document root of the domain name? Thank you. 0
Please sign in to leave a comment.
Comments
1 comment