1

Is it possible to set up a Drupal website so that other domain names can go to specific nodes but show the domain name instead of the natural URL in the address bar? Can I use the Domain module, or some other method, so that example2.com goes to example.com/page2 but still shows example2.com in the address bar?

Any internal links still go to example.com/whatever, and that's fine. The page is designed as a one page unbranded website.

I already have the domain (example2.com) pointed to our servers (example.com) and have some familiarity with setting up vhosts in apache if needed as part of the Domain module set up. I'm not sure if I'm understanding what this module does and if it will do this job. I've also posted on Server Fault but am not getting anywhere because I think I'm not asking the question properly.

Drupal 7.59. Debian and Apache

6
  • This is more a question of Apache config and therefore better asked on other SE network sites.
    – leymannx
    Jun 24, 2018 at 21:36
  • Why not use the same Drupal site and just remove the branding for that particular node?
    – No Sssweat
    Jun 25, 2018 at 5:50
  • 1
    leymannx, there are multiple ways to do it and some are Drupal specific. Posting here just in case. Here's my other post in server fault. serverfault.com/q/918033/378963 Also, no sssweat, this is exactly what I've done and now the node needs its own domain name.
    – Christia
    Jun 25, 2018 at 6:11
  • Absolutely! But in this case there's nothing Drupal can do :/
    – leymannx
    Jun 25, 2018 at 8:17
  • 1
    Actually you might get away with using the domain module and setting the home page for example2.com to the required path (with the relevant content shared across both domains obviously). No idea how you’d begin to solve the relative link problem though. And a heavy module like domain seems massively overkill for such a simple requirement IMO
    – Clive
    Jun 28, 2018 at 7:06

1 Answer 1

1

I was able to set different domain-based landing pages for existing nodes of our main site using the Domain module. This module is fairly complex and will either be exactly what you need, or not.

Our use case is that we have multiple one-page partner projects, such as campaigns, that need their own domain name but that share content from our regular website, such as our blogs.

The following are the steps taken for Drupal 7.

Be sure to read the entire readme file, the quick install and the install instructions before starting. There are many variables specific to your use case and environment.

Step 1

In order to use it, you will need to be able to configure the domains on the server to reference the primary website's docroot. In my case, that means I needed to point the domains over to the same server, and set up different vhost files as follows:

<VirtualHost *:80>
        DocumentRoot "/var/www/html/example/docroot"
        ServerName example2.com
</VirtualHost>

Step 2

You will then need to add some code to your sites/default/settings.php. Make sure the path is correct, according to your set up.

/**
 * Add the domain module setup routine.
 */
include DRUPAL_ROOT . '/sites/all/modules/contrib/domain/settings.inc';

Step 3

Once this is done, install the domain module and enable only the domain module, but none of the submodules yet. Then rebuild permissions (/admin/reports/status/rebuild). Then enable the domain_conf anddomain_settings and any others. Once enabled, set your primary domain to default.

enter image description here

Step 4

Add your new domains by clicking on "Create domain"

Step 5

In order for the blog and other relative links to go back to the primary domain, I needed to set the following in advanced settings (Structure > Domains > Settings):

enter image description here (Here, FosterClub is my primary domain).

After this, there are other sub-modules you can enable to further customize what you need to accomplish. Be sure to set your permissions. You are also able to assign domain access to specific roles and users, which allows them to edit and create content restricted to specific domains, using the "edit domain content" permission, with the domain_content sub-module: enter image description here This is a screenshot of settings under a specific user. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.