Point additional domain to a sub-site

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
no2e's picture

I have a multi-site installation like

  • example.com/drupal (default)
  • site1.example.com
  • site2.example.com
  • site3.example.com

example.org → site3.example.com

Now, I have an additional domain example.org, which shall be used for site3.example.com. So, when a user enters example.org, he shall be redirected(?) internally(!) to site3.example.com. So, the user shall not see any redirection and he shall not be able to see, that the site is available at site3.example.com, too.

site3.example.com → example.org

When the user enters site3.example.com directly, it would be cool if he would get redirected(?) to example.org. But that's no need (but then it should be possible to use robots.txt for site3.example.com, though, so that I don't get duplicate content)

Where is the problem?

So, why not point example.org to the Drupal multi-site installation directly (and use it instead of site3.example.com)? Well, that is not possible, because at my shared webhoster I can't point example.org to a directory at example.com.

Is it possible?

Maybe with the help of mod_rewrite/.htaccess?

I want to stay independent of example.org in a way. It might be possible that the domain will be selled, and the new owner shall be able to point this URL still to my site (and the users shall only see his URL, not the "real" address of my site). So, my site shall always "be there" (at site3.example.com), no matter whether example.org is active or where it leads too.

Comments

Any idea?

no2e's picture

Would be very nice.

In the mean time I read something of "A Records", but I don't have this functionality :/

settings.php trick

cweagans's picture

Install your site at example.org (this is just to simplify things). Build all your content at example.org.

Create a folder in /sites for site3.example.com
Create settings.php in /sites/site3.example.com
In /sites/site3.example.com/settings.php, put this:

<?php
header('Location: http://www.example.org');
exit();

When you go to example.org, you will see the content for example.org

When you go to site3.example.com, you will get redirected to example.org

Alternatively, build the site at example.org, then do this stuff in a terminal

cd sites
mkdir site3.example.com
cp example.org/settings.php site3.example.com/settings.php
cd site3.example.com
ln -s ../example.org/files files
ln -s ../example.org/modules modules
ln -s ../example.org/themes themes

This will make site3.example.com pull from the same database, files, modules, and themes that example.org pulls from.

--
Cameron Eagans
http://www.blackstormsstudios.com

--
Cameron Eagans
http://cweagans.net

Hm, I think I did not get it

no2e's picture

Hm, I think I did not get it fully ...

The site is installed at "example.com/drupal" -- I don't want to change this anymore.
A subsite of this multisite-installation is "sport.example.com". This works great.

Now I want to use the domain "sport.tld" for this subsite.

So, when a visitor enters "sport.tld/node/17", he gets the page "sport.example.com/node/17" -- but without noticing it. So the URL bar should still show "sport.tld/node/17".

And I'd love to get this by adding a htaccess to sport.tld
(the domain might change ownership, and the new owner shall be able to use his new domain to get the content of my site)

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week