Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

Serving the same files to two different addon domains

Discussion in 'General Discussion' started by kadeo, Sep 28, 2017.

  1. kadeo

    kadeo Registered

    Joined:
    Sep 28, 2017
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Belfast
    cPanel Access Level:
    Website Owner
    Hi all.

    First time poster, and relatively new and self taught developer. Be gentle! :)

    Ok, So I have two addon domains against my main domain... maindomain.uk, addondomain.uk and addondomain.ie (the same domain name but different TLDs). For the most part, the two addon domains will be completely different from each other. However, I want to run the same forum on both of them. I'm using SMF for the forum software if that info is any use.

    While I'm pretty sure I can figure out how to get the forums on both addon domains to use the same database, and so effectively be the same forum, it seems like I should go a step further and actually serve the forum software files from the same location too. So that if a change is required, that I'm only having to do it once and both domains will see the updates.

    My hosting provider suggested a .htaccess redirect but my understanding of this is that the browser will be redirected to a different page rather than just the file requests of the server being redirected. I want addondomain.uk/community and addondomain.ie/community to remain distinct URLs but serve the same files.

    Please ask me questions to clarify if I haven't done a good enough job of doing that already.

    Hope you can help. Thanks.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Have you considered configuring the addon domain names to have the same document root? You can modify the document root via the Addon Domains option in cPanel so that each domain name shares the same document root.

    Thank you.
     
  3. kadeo

    kadeo Registered

    Joined:
    Sep 28, 2017
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Belfast
    cPanel Access Level:
    Website Owner
    Hi, Thanks for the reply. I had considered that but its only the forum that that should be shared between the two domains. The rest of the pages on the sites will be completely different.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    You could still upload the separate pages to the same directory, or within a subdirectory of the document root. Otherwise, you may need to consider uploading a separate set of files to a separate directory for use with the additional domain name, and then setting up a cron job that copies over the files from the first domain name's document root to the second domain name's document root.

    Thank you.
     
  5. kadeo

    kadeo Registered

    Joined:
    Sep 28, 2017
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Belfast
    cPanel Access Level:
    Website Owner
    Let's say I did that, what about the index.html at the root? If someone goes to addondomain.uk or addondomain.ie, wouldn't they get the same page then?

    I don't think I understand. Do you mean like every time I make a change to the forum files on one site, run a cron job to update the other site? This would still mean I would have two sets of files doing the same thing. What kind of developer would I become if I didn't at least try and use DRY principles? lol

    Could subdomains help me here? If I set up a 'community' subdomain on both domains and have them both pointing to the same folder, could that do the trick? There will be some settings that would be individual to each site that I'll need to overcome somehow, like anything to do with a URL or email address.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Yes, that's correct. If you need separate index pages, then the better approach would be to use separate document roots and sync the shared files via a cron job using a utility such as rsync.

    Yes, this approach would work. You could configure the same document root for both subdomains, and at the same time utilize separate document roots for the primary domain names so they can use their own custom files as well (e.g. index.html).

    Thank you.
     
Loading...

Share This Page