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!

Display Content From primary.com When Visiting secondary.com Without Changing URL In Browser

Discussion in 'General Discussion' started by jc4400, Dec 11, 2018.

  1. jc4400

    jc4400 Registered

    Joined:
    Dec 11, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Illinois, USA
    cPanel Access Level:
    Root Administrator
    After two full days of Googling, learning, testing, and failing repeatedly, I humbly come to this forum in search of guidance.

    I use WHM on a VPS. I have two domains, lets call them primary.com and secondary.com. I need the URL secondary.com/account(.*) to display content from primary.com/account(.*) without changing the URL in the user's browser.

    Initially I had a unique cPanel account established for each domain. I created a custom httpd.conf and saved it at /etc/apache2/conf.d/userdata/ssl/2/secondary/primary.conf and it contained the following:

    Alias "/account" "/home/primary/public_html/account"
    <Directory "/home/primary/public_html/account">
    Require all granted
    </Directory>

    I rebuilt httpd.conf and restarted Apache. When I visited secondary.com/account I saw a Forbidden 403 error because each account had a different user and did not share the same permissions.

    I then tried creating a new group and adding both users in said group, but that did not help.

    I scrapped all of that and tried a new approach. I deleted the secondary.com cPanel account and then created a cPanel AddOnDomain in primary.com where secondary.com is the AddOn. I assumed this would eliminate the user permission issue, but now I don't see a /etc/apache2/conf.d/userdata/ssl/2/secondary directory and thus can not try adding a new custom httpd.conf file for secondary.com.

    Can anyone suggest a solution that will allow me to display content from primary.com/account(.*) when someone visits secondary.com/account(.*) without changing the URL in the user's browser? Thank you in advance for any assistance you can provide.

    P.S. - We eventually will have hundreds of unique secondary domains that will have the same relationship with the primary domain.
     
  2. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,372
    Likes Received:
    154
    Trophy Points:
    193
    Location:
    Chesapeake, VA
    cPanel Access Level:
    DataCenter Provider
    All you really need to do here is set up secondary.com as a domain alias to primary.com and make sure you don't have any htaccess redirects that pushes content over to primary.com.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. jc4400

    jc4400 Registered

    Joined:
    Dec 11, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Illinois, USA
    cPanel Access Level:
    Root Administrator
    My understanding is a domain alias would make both sites contain the content of primary.com. In my case, secondary.com is a unique website with its own content; we only want to share the "account" directory - primary.com/account - on both websites.
     
  4. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,372
    Likes Received:
    154
    Trophy Points:
    193
    Location:
    Chesapeake, VA
    cPanel Access Level:
    DataCenter Provider
    That's tougher for the reasons you encountered. Have you considered syncing the folder over from the other account?

    This is probably a better idea. Add sdcknday.com as a addon domain to primary.com that way they use the same user but have different docroots. Then your symlink would work fine.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. jc4400

    jc4400 Registered

    Joined:
    Dec 11, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Illinois, USA
    cPanel Access Level:
    Root Administrator
    Where would symlink be recorded on the server when secondary is an addon? I do not see /etc/apache2/conf.d/userdata/ssl/2/secondary when secondary is an addon.
     
  6. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,372
    Likes Received:
    154
    Trophy Points:
    193
    Location:
    Chesapeake, VA
    cPanel Access Level:
    DataCenter Provider
    The symlink is at the file system level and does not need to be configured in Apache
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,009
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @jc4400,

    Are you attempting to replicate the account directory and have the data stored in a separate database for the separate domain name? Or, do you want both domain names to load and utilize the exact same content? Will the contents of this directory change or remain static?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. jc4400

    jc4400 Registered

    Joined:
    Dec 11, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Illinois, USA
    cPanel Access Level:
    Root Administrator
    Both domains would load and utilize the exact same content and use data stored in primary.com's mySQL database. Any content changes would occur on primary.com and those changes would appear on all domains. To put that another way: primary.com/account would be the only directory containing content. All secondary.com/account directories would be shells pulling content from primary.com/account
     
  9. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,009
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi @jc4400,

    In this case, you'd setup secondary.tld as an addon domain name with it's own document root. Within it's document root, you could setup a symbolic link pointing "account" to the "account" directory under the document root of "primary.tld". Or, another option is to setup the "account" directory as a source git repo, and then clone/sync the repo to the "account" directory for "secondary.tld":

    Guide to Git - cPanel Knowledge Base - cPanel Documentation
    Git Version Control - Version 76 Documentation - cPanel Documentation

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice