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

jc4400

Registered
Dec 11, 2018
4
0
1
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.
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,779
331
363
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.
 

jc4400

Registered
Dec 11, 2018
4
0
1
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.
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,779
331
363
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @jc4400,

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.
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.
 

jc4400

Registered
Dec 11, 2018
4
0
1
Illinois, USA
cPanel Access Level
Root Administrator
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.
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
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
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.