1

I want to build a drupal site in D7 that can host thousands of parked domains as landing home pages. The purpose is to create a system for a domain broker to host many parked domains, each with its own sales page on its parked domain root.

The domain access module serves similar purpose but my experience is that it works for up to 10 domains, after that there are serious usability and performance issues arising.

So I'm looking for a simple alternative. What I need is only one page per domain, with the domain as title (example.com) and a contact form that potential buyers of the domain can use.

Assumption: the 1000 domains have been parked on the drupal installation domain.

If I create 1000 nodes hwith corresponding titles (example.com) how do I make each node the homepage of each parked domain? Maybe using .htaccess rewrites, but Im not good at that. The parked domain must stay as browser address when redirected.

Alternative might be to create one custom panel page and use tokens to use the domain URL in the title and the sales text and contact form. The contact form is just a standard contact form that sends an email to the site administrator.

3 Answers 3

1

I'm assuming you have a field on your nodes with the name field_domain.

On your website:

  1. Create a new node. This will be a place holder.
  2. Get the NID.
    a) Go go /admin/content/
    b) Click edit on this placeholder node c) Check the url. It will be in the form:
         /node/<NID>/edit
        Get that NID.
  3. Go to your theme.
  4. On the templates folder, create a file with the name:
    node--NID.tpl.php so something like: node--78.tpl.php
  5. On this file, put the following content:
  <?php
    $query = new EntityFieldQuery();

    $query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'article')
      ->propertyCondition('status', 1) // published
      ->fieldCondition('field_domain', 'value',  $_SERVER['SERVER_NAME'], '=');
    $result = $query->execute();

    $nid = array_keys($result['node'])[0];
    if($nid) {
      $nodeObj = node_load($nid);
      $nodeRndr = node_view($nodeObj);
      print(drupal_render($nodeRndr));
    }

    You need to update 2 things:

     article to the machine name of the content type you're using.
     field_domain to the machine name of the field you're using.

  1. Now, go to admin/config/system/site-information
  2. Change the front page to node/NID where NID is the value from #4.

Explanation:

What that code does is checks $_SERVER['SERVER_NAME']. This should be the domain that's being used. Using that, it looks to see if there's a node with the field field_domain that has a value that matches $_SERVER['SERVER_NAME'].

If there's a match, it will load the node and render it.

If not, it should still load the placeholder node you created. This could be your default home page.

Hope this helps.


Original comment:

Have you considered writing some custom code?

If the only thing different is the title. I would create a small module that:

  1. On installation creates a table with a domain and a title column.
  2. When a page loads, reads the table and matches the domain and selects the title.
  3. With the title, on... hook_preprocess_page (probably) you can set the title

I think there's a bit more functionality you want. If you're acting like a broker or if it's only a single owner, you probably are sending an email. So you would need the domain that was visited in the form as a minimum.

You can do this by having a hidden field and setting the value on load as well.

Or when submitting the form, reading it and processing it.


If it's more like a marketplace and you're sending an email to the owner which would vary per domain.

I think that processing that after the fact and only having one form would probably be more efficient than having a form per domain.


It depends on the use case. Just offering another option.

8
  • Thanks, yes I'm acting as a domain broker. And I'm not a module developer :-( but can create panel pages using tokens, which might also work?
    – Yuri
    Commented Oct 5, 2016 at 19:34
  • > Assuming that the 1000 domains have been parked on the drupal installation domain, and the 1000 nodes/entities have been created with corresponding titles, how do I make each node the homepage of each parked domain? Based on this, what I think you're missing is a way to find/load the right node/form based on the domain? ------ @Yuri Could you update your original message with what should happen when submitting the form? and fields you have on your custom form/content type? Maybe with a bit more context there's another solution.
    – rovr138
    Commented Oct 5, 2016 at 19:49
  • Yes, I'll update the description.Why I said assuming the nodes are present, is because I need a sales text on each landing page thats secific to the domain. To link the domain to the pages could be done with a htaccess rewrite.
    – Yuri
    Commented Oct 5, 2016 at 19:58
  • Is the form specific to the domain? Is there a field in the node that has the domain?
    – rovr138
    Commented Oct 5, 2016 at 20:43
  • The form is not specific to the domain, can be embedded as single form (with tokens in emails for domain etc). Yes the node contains a field with the domain name (an entity reference to a domain entity)
    – Yuri
    Commented Oct 5, 2016 at 20:52
0

You can think of having multi site architecture, basically different sites sharing same code base or they can have site specific codebase but different database.

OR

You can try following:-
- Comnination of Subdomain and Organic Group.
- Just Subdomain module

2
  • I know about multisites but bulk creating 1000nds of them I don't know.
    – Yuri
    Commented Oct 5, 2016 at 19:40
  • Subdomain module may not be suitable because I want the root url of the parked domains to stay the same for the user.
    – Yuri
    Commented Oct 5, 2016 at 19:42
0

Although the answer of rovr138 works for rendering the landingpage node on the homepage, it is rendered inside another node by modifying its template. The drawback of this solution is that tokens or panel context keywords are not available for the landingpage, since its rendered inside another node. Including landing page info on the forms in the landingpage is essential. There may be a workaround for this, but I eventually chose for the simple solution of including the folling rewriterule in my .htaccess file, in which 'example.com' is my company homepage:

  # Rewrite Request for parked domains '/' to landing page
  RewriteCond %{HTTP_HOST} !=example.com
  RewriteCond %{HTTP_HOST} (.+)\.(\w+)
  RewriteRule ^/?$ ?q=landingpage/%1-%2 [L]

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.