How to map different subdomains to the same directory?

I want to configure multiple subdomains to point to the same directory (document root), but I do not have access to the server configuration (Apache/Nginx). I am using a hosting provider with limited access (shared hosting).

Goal

I have:

  • a.example.com
  • b.example.com

And I want both to serve content from the same folder, for example:

public_html/myapp

Current situation

  • Both subdomains are already created in the hosting panel
  • By default, each subdomain points to its own folder

What I want

Instead of separate folders, I want:

  • a.example.compublic_html/myapp
  • b.example.compublic_html/myapp

Constraints

  • I cannot edit Apache/Nginx config (no access to virtual hosts)
  • I only have access to:
    • Control panel (e.g., vPanel)
    • File manager / FTP
    • .htaccess

Question

What is the best way to make multiple subdomains point to the same directory in this situation?

  • Is there a way to configure this via the hosting control panel?
  • Can this be achieved using .htaccess (rewrite or redirect)?
  • Or is there another workaround (e.g., symlinks, addon domains, etc.)?

Not possible on free hosting as Addon domains can only be the base domain. Best way to do this is just setup a redirect from subdomain a to subdomain b

You could probably set up a PHP script on site A to read the files from the site B and proxy them.

I don’t think that will work due to openbasedir restrictions.