I have the following problem: I would like to have one craft backend / one installation for different one pager sites on different domains. The reason is, that we have one HTML template we would like to use for our landing pages for different purposes (e.g. landingpage with different testimonials) and we would like to use a different domain for each version of the landingpage.

My initial thought was, to build a channel and to setup it up like www.domain.com/landingpage01, www.domain.com/landingpage02 etc.

So how do I route mycooldomain.com to /landingpage01 and myothercooldomain.com to /landingpage02?

Or are there any other solutions for my problem?


One way to do this, is use different environments for each domain and set a variable (for instance, an entry ID) for each environment. So, your config/general.php would look something like this:

return array(
   '*' => array(
       // Every config setting that's the same for all domains (like devMode, omitScriptNameInUrls, etc.
   'firstDomain.com' => array(
       'siteUrl' => 'http://www.firstDomain.com/',
       'environmentVariables' => array(
           'baseUrl' => 'http://www.firstDomain.com/', // For use in asset source, for example
           'basePath' => '/path/to/public/folder/', // Same for this
           'entryId' => 5 // Or whatever the ID of your entry is
   'secondDomain.com' => array(
       'siteUrl' => 'http://www.secondDomain.com/',
       'environmentVariables' => array(
           'baseUrl' => 'http://www.secondDomain.com/', // For use in asset source, for example
           'basePath' => '/path/to/public/folder/', // Same for this
           'entryId' => 8 // Or whatever the ID of your entry is

Then, in your template (entry.html or whatever file you use as your section's template), you get the data like this:

{% set entry = craft.entries.id(craft.config.environmentVariables['entryId']).first() %}

<h4>{{ entry.title }}</h4>
  • Thanks, that worked well, but the entryId is being ignored. The setup is exactly as yours, the second domain shows the index page (Homepage), but the section entryId. Any idea? Jun 30 '15 at 13:52
  • Edit: I managed to get data from the entry shown in the config, but it only loads the index template and not the _entry template. Jun 30 '15 at 14:21
  • This looks like a more solid approach: codepad.co/snippet/YEt1ukTt What do you guys think? Sep 24 '16 at 7:21

Found the solution:

I did as written above and added

{% include "landingpages/_entry" %}

to my index.html.

Thanks. I <3 Craft.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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