Subdomain redirection to new domain

Discussion in 'Site & Server Administration' started by midi, Dec 16, 2012.

  1. #1
    Hi all,

    I would truly appreciate if someone could point me in the right direction about the following.

    I have a domain with 150 subdomains. THey are all working well. Lets call them:

    sudomain1.domain.com
    sudomain2.domain.com
    sudomain3.domain.com
    sudomain4.domain.com
    sudomain5.domain.com

    I would like to do the following in one of the subdomains, for example, subdomain3.domain.com

    I would like to display what is currently under that subdomain as a different domain... that is, display what i have hosted in subdomain3.domain.com now, with new domain: newdomain.com

    I have already pointed newdomain.com to the IP that hold this subdomain, but now i do not know how to direct the person that types such url to the specific new subdomain, that is, show the content of subdomain3.domain.com when someone types newsubdomain.com.

    I have the website with a Plesk Panel. Is this something i need to do within Plesk (Version 9.5.4)? or may i do it in another way through code?

    Your help pointing me in the right direction would be deeply appreciated. Thanks!
     
    midi, Dec 16, 2012 IP
  2. Cybercon

    Cybercon Active Member

    Messages:
    103
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    88
    #2
    You can use DNS to do the redirect. Use cname in DNS.
     
    Cybercon, Dec 18, 2012 IP
  3. midi

    midi Active Member

    Messages:
    247
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks Cybercon, but not sure if i understood you correctly. Basically newdomain.com is already pointed to the server (through the domain registrar).. the only pending thing is that the server that holds the subdomains (to which nwdomain.com is pointing) needs to know to which one of the subdomains (of the 150 I have) it should redirect "newdomain.com".... I understand this is something that should be done at the server level that holds the subdomains...

    If what you mean is use cname in DNS at domain registrar, that has already been done. If you mean something else, please explain further so I can understand better what you mean. Thanks!
     
    midi, Dec 18, 2012 IP
  4. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #4
    Midi,

    In order for the domain you wish to use to display the respective sub-domain to actually show up, it will need to be added to the sub-domain's virtualhost configuration, for example:

    <VirtualHost IP:80>
    ServerName subdomain1.domain.com
    ServerAlias newdomain.com
    </VirtualHost>
     
    zacharooni, Dec 23, 2012 IP
    midi likes this.
  5. cybermichail

    cybermichail Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    Zacharooni`s answer is best solution I think.

    But , may be better this will as in apache docs.

    <VirtualHost IP:80>
    ServerName newdomain.com
    ServerAlias subdomain1.domain.com
    ServerAlias subdomain2.domain.com
    ServerAlias subdomain3.domain.com
    </VirtualHost>

    Please sorry if I made a mistake.
     
    cybermichail, Dec 25, 2012 IP
  6. cybermichail

    cybermichail Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    <VirtualHost IP:80>
    ServerName newdomain.com
    ServerAlias subdomain3.domain.com
    </VirtualHost>
     
    cybermichail, Dec 25, 2012 IP
  7. midi

    midi Active Member

    Messages:
    247
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #7
    Thanks a lot Zacharooni for your help in this.

    Thanks Zybermichail por your input and confirmation... but you posted this & changed the order of serverName & serverAlias from what Zacharooni changed. Do you think this is the correct order?
     
    midi, Dec 26, 2012 IP
  8. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #8
    Technically, they would both do the same thing, however if the Apache configuration is managed by means of a hosting panel like cPanel, then the changes will revert themselves upon the next rebuild. If you do run cPanel, then you can do what's called Parking a domain, which essentially inserts the ServerAlias into the rebuilt configuration, which takes care of the folder and domain mapping.
     
    zacharooni, Dec 28, 2012 IP
  9. midi

    midi Active Member

    Messages:
    247
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #9
    Thanks again Zacharonni!

    If we do it the way you have mentioned, will the server have any side effects in case we have more than 1000 sub domains that are redirected to different domains?

    Currently we run around 160 subdomains and use Drupal that automatically does the mapping of subdomains. We are looking forward to move to a custom based solution in php and want our solution to be as scalable as it is currently in terms of creating subdomains. Please let me know.
     
    midi, Jan 8, 2013 IP
  10. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #10
    midi,

    Not a problem. Other than taking Apache slightly longer to restart, because of the number of subdomains. If Drupal automatically handles the subdomain creation, why don't you just use a wildcard subdomain, that is to say, park *.yourdomain.com to a specific folder, point * A record to the IP of your website, and essentially anything.yourdomain.com will point to that folder on that IP, while Drupal handles the subdomain redirection.
     
    zacharooni, Jan 11, 2013 IP