The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Easier way to redirect subdomain pages to new domain

Discussion in 'Workarounds and Optimization' started by M Rich, Mar 8, 2017.

Tags:
  1. M Rich

    M Rich Registered

    Joined:
    Mar 8, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    North Carolina
    cPanel Access Level:
    Root Administrator
    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.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page