Pointing a domain to another domain's subfolders


I have two registered domains, for example purposes domain1.com and domain2.com. Is there a way to have it so that when someone goes to domain2.com it will redirect to domain1.com/subfolder and everything within domain1.com/subfolder will be accessed as if it is domain2.com? To include being able to directly address www.domain2.com/games and it point to domain1.com/subfolder/games ?


You can use the Redirect directive in domain2’s .htaccess file to redirect all URLs from domain2 to domain1. Something like this (untested code):


Redirect permanent / https://domain1.com/subfolder

The Redirect directive automatically matches all sub-paths, so /games will redirect to https://domain1.com/subfolder/games.


Upon redirecting to domain1.com/subfolder/games by the use of domain2.com/.htaccess, will the address bar/URL show as www.domain2.com/games as if mirrored or will it reveal www.domain1.com/subfolder/games ?


yes that is definitely possible.
Even i am working on it but haven’t reached to a solution.
but i surely believe in this community,they would help.
Thank you in advance.


The .htaccess rule redirects visitors to a new URL, so the address bar URL will change from domain2.com/games to domain1.com/subfolder/games. For mirroring, a different techniques would be needed.


I attempted to set domain2.com up as a mirror in the DH manage domains section but it seems to only allow me to set domain2.com to mirror domain1.com and not domain1.com/subfolder. I have looked for additional options within the mirror set up and cannot find any. I guess what I had envisioned, which I can’t figure out how to make work, is for domain2.com to be the apparent root that is really in domain1.com/subfolder with no indication of domain1.com in the URL. I’m trying to set up two web site that share the same SQL user tables (multi-site setup).

I guess I’m finding out that it isn’t possible?


So to mirror a subdirectory, I think you could use a symbolic link, assuming both domain are hosted under the same shell user. For example, subfolder would be a symbolic link pointing to the domain2.com directory:

├── domain1.com
│   └── subfolder -> ../domain2.com
└── domain2.com
    └── games
        └── index.html

Another option might be to set up a reverse-proxy, but it might not be available, depending on your account type (Shared/VPS/etc).


Thank you, I’ll give that a try. Seems a little complicated for my experience (or lack thereof) level.


Another option I forgot to mention is sub-directory remapping, which can be setup in the control panel:


If that works for you, it is probably a better option then symlinks.


Thank you Habilis. I tried several times to do the sub-directory remapping in control panel and it apparently will not configure the way I am hoping for.

I enter the fully hosted URL to remap http://www.domain1.com/subfolder. No issue here.
Then is asks for the new path on my server which I choose /home/domain2/ and leave subfolder path enpty because I want the full domain2 to remap to domain1.com/subfolder. The remapping is not accepted and returns “Error: The URL must only contain letters, digits, ‘-’ ‘_’ ‘.’ or ‘/’”.


Here’s what the remap setting should look like, assuming domain2.com is being served from the file path /home/user/domain2.com. The new path can’t be empty (i.e. you can’t serve the user’s home directory):

Remap settings

Possibly you have a user named “domain2”, in which case the path to the domain2.com site root directory might be /home/domain2/domain2.com?


I followed the remap setting per your example. Now when I go to url www.domain2.com, it takes me to www.domain2.com/subfolder but it’s empty. Yet when I FTP to www.domain1.com/subfolder, where domain2.com should remap to, content is there.

I thought in the beginning I did but apparently did not, specify that domain2.com is not a fully hosted domain but rather mirrors domain1.com. So I think now that I have the redirect setup as you stated to do, the link is possibly pointing to an empty domain2.com?


Ah, I see. Yes, all my suggestions assume you are starting with two fully hosted domains setup in a plain vanilla way (no .htaccess, symlinks or remapping). Also each suggestion is mutually exclusive. Mixing them will cause trouble.

Mirroring sites makes them 100% identical, but you only want them partially identical, so you can’t use mirroring.


It is evident that what I want to do is impossible. Thank you so much for your time in assisting though.