<p>Yes, it is possible to have a Craft install on multiple domains and subdomains as long as you only access the control panel from a single domain and you only have a single installation of craft that all the domains and subdomains use.</p>

<p>The limitation is all domains would be using the same url router and content - although for multi language content having different domains might be the way to switch on which language to use.</p>

CC BY-SA 3.0
2014-06-12T10:45:19.520Z
I'd like to see an example or tutorial for that kind of setup.  Using subdomains for the locals seems to make much more sense than url segments.
Steve Adams
CC BY-SA 3.0
2015-08-20T18:04:01.513Z
Found the multiple subdomain feature extremely useful for making a dev.site.
Matteo
CC BY-SA 3.0
2014-06-12T03:20:32.153Z
2014-06-12T03:20:32.153Z
Luke Holder
<p>No you can't. In Craft's early days, they had a MSM-like (ala ExpressionEngine) feature, but they eventually removed because it overcomplicated the system.</p>

<p>You will have to run a unique craft install per domain. However, these Craft installs can at the very least share the same craft/app folder: <a href="http://buildwithcraft.com/help/sharing-craft-files" rel="nofollow">http://buildwithcraft.com/help/sharing-craft-files</a></p>

CC BY-SA 3.0
2014-06-12T03:24:02.230Z
the question was asking if you can use different domains which is true, what you cant do is use the same install to run different website that have different content and url structures. See my answer below.
Luke Holder
CC BY-SA 3.0
2014-06-13T13:31:36.293Z
My mistake. I misunderstood the question. :)
tnypxl
CC BY-SA 3.0
2017-08-09T16:40:22.037Z
@tynpxl, I found your answer very helpful. My interpretation of the original question was exactly like yours.
PKHunter
CC BY-SA 3.0
2014-06-12T01:25:51.807Z
2014-06-12T01:25:51.807Z
tnypxl
<p>I was also looking for an elegant solution to server multiple domain from the same Craft instance and this is what I found.</p>

<p>The multiple domains documentation will assist your domain setup and is pretty easy: <a href="http://buildwithcraft.com/docs/multi-environment-configs" rel="nofollow">http://buildwithcraft.com/docs/multi-environment-configs</a></p>

<p>Where I got hung up is adding content which is specific to one domain.  The only 'hacky' work around I could come up with was using rewrite rules (.htaccess, etc) to append the request with a url segment that could be targeted via routes.</p>

<p>example.com -> main site
example2.com -> landing page site.  .htaccess rewrites to example2.com/lp/news</p>

<p>In the example above, I could also access the /lp/news from blog.example.com unless I want to manage conditionals in configs / .htaccess (for this domain, not this domain, etc).</p>

<p>At the end of the day, it's pretty clear Craft isn't intended for multiple sites and I don't recommend solutions that become a spaghetti mess to manage.  If it's a landing page or two, I think using the combination of configs, routes and rewrite rule would do the trick...anything else I would look into a separate instance.</p>

CC BY-SA 3.0
2014-06-12T15:55:37.457Z
2014-06-12T15:55:37.457Z
nateiler
<p><strong>Update for Craft 3</strong></p>

<p>Craft 3 includes native support for multi-site installation. <a href="https://docs.craftcms.com/v3/sites.html" rel="nofollow noreferrer">Here's a link</a> to the official docs and <a href="https://craftcms.stackexchange.com/questions/19601/multi-site-setup-in-craft3">here's a link</a> to another question with more resources.</p>

<p><strong>Old answer for Craft 1 &amp; 2</strong></p>

<p>Credit to @LukeHolder for the original answer, but here's a bit more detailed and technical answer. Note, this might not be possible on all hosts.</p>

<p>Place the craft folder above both domains, add Craft's index.php file to both domain web roots and set the $craftPath variables in them to point to the same craft folder.</p>

<p>To make a template (say for a blog) only load on its own subdomain instead of whenever any of its slugs are requested on <em>any</em> domains you can run this quick check:</p>

<pre><code>{% set domain = craft.request.getServerName() %}

{% if not domain starts with 'blog' %}
    {% redirect '404' %}
{% endif %}
</code></pre>

<p>This will make "blog.example.com/some-blog-post" load, but "example.com/some-blog-post" will redirect to the 404 page.</p>

<p>Links to posts can formatted like this to add the subdomain to the URL:</p>

<pre><code>http://blog.example.com/{{ entry.uri }}
</code></pre>

<p>While this isn't an end all solution, it is a functional workaround, especially if it's only for page or two. Use Craft 3 if you can.</p>

CC BY-SA 3.0
2014-06-12T07:07:03.537Z
Simon, how do I add the subdomain to automatically generated links from a (redactor) rich text field? Is this possible?
carlcs
CC BY-SA 3.0
2014-06-12T19:01:48.050Z
Short of manually editing the links I don't know of any good options.
Simon Kuran
CC BY-SA 3.0
2014-06-16T07:50:19.360Z
try putting {siteUrl} into the craft config? http://glui.me/?i=ao3ste0jh061kdj/2014-06-16_at_3.49_pm.png/
Luke Holder
CC BY-SA 3.0
2014-06-16T21:00:20.517Z
I don't see what that would do as Craft would still have no idea what sections load at what URLs.
Simon Kuran
CC BY-SA 4.0
2014-06-12T06:48:26.863Z
2018-06-06T05:24:23.733Z
2018-06-06T05:24:23.733Z
Simon Kuran
<p>Is it possible to have one Craft install running multiple domains and/or subdomains?</p>

<p>For example having the same Craft install running a blog Channel at blog.example.com and also an about Single at example.com/about.</p>

<config><server><multi-site><deployment>
Can I run one Craft install on multiple domains and/or subdomains?
# Can I run one Craft install on multiple domains and/or subdomains?

(Asked by: username_0 on 2014-06-12)

Is it possible to have one Craft install running multiple domains and/or subdomains?

For example having the same Craft install running a blog Channel at blog.example.com and also an about Single at example.com/about.

**Tags:** config, server, multi-site, deployment

---

## 4 answers

### Answer by username_0 on 2014-06-12. Score: 12 | Accepted answer

Update for Craft 3
Craft 3 includes native support for multi-site installation. Here's a link to the official docs and here's a link to another question with more resources.
Old answer for Craft 1 & 2
Credit to @LukeHolder for the original answer, but here's a bit more detailed and technical answer. Note, this might not be possible on all hosts.
Place the craft folder above both domains, add Craft's index.php file to both domain web roots and set the $craftPath variables in them to point to the same craft folder.
To make a template (say for a blog) only load on its own subdomain instead of whenever any of its slugs are requested on any domains you can run this quick check:
{% set domain = craft.request.getServerName() %}

{% if not domain starts with 'blog' %}
    {% redirect '404' %}
{% endif %}

This will make "blog.example.com/some-blog-post" load, but "example.com/some-blog-post" will redirect to the 404 page.
Links to posts can formatted like this to add the subdomain to the URL:
http://blog.example.com/{{ entry.uri }}

While this isn't an end all solution, it is a functional workaround, especially if it's only for page or two. Use Craft 3 if you can.

> **Comments:**
> **username_7**: Simon, how do I add the subdomain to automatically generated links from a (redactor) rich text field? Is this possible?  
> **username_0**: Short of manually editing the links I don't know of any good options.  
> **username_1**: try putting {siteUrl} into the craft config? http://glui.me/?i=ao3ste0jh061kdj/2014-06-16_at_3.49_pm.png/  
> **username_0**: I don't see what that would do as Craft would still have no idea what sections load at what URLs.  

---

### Answer by username_1 on 2014-06-12. Score: 10

Yes, it is possible to have a Craft install on multiple domains and subdomains as long as you only access the control panel from a single domain and you only have a single installation of craft that all the domains and subdomains use.

The limitation is all domains would be using the same url router and content - although for multi language content having different domains might be the way to switch on which language to use.

> **Comments:**
> **username_2**: I'd like to see an example or tutorial for that kind of setup.  Using subdomains for the locals seems to make much more sense than url segments.  
> **username_3**: Found the multiple subdomain feature extremely useful for making a dev.site.  

---

### Answer by username_4 on 2014-06-12. Score: 3

No you can't. In Craft's early days, they had a MSM-like (ala ExpressionEngine) feature, but they eventually removed because it overcomplicated the system.

You will have to run a unique craft install per domain. However, these Craft installs can at the very least share the same craft/app folder: <http://buildwithcraft.com/help/sharing-craft-files>

> **Comments:**
> **username_1**: the question was asking if you can use different domains which is true, what you cant do is use the same install to run different website that have different content and url structures. See my answer below.  
> **username_4**: My mistake. I misunderstood the question. :)  
> **username_5**: @tynpxl, I found your answer very helpful. My interpretation of the original question was exactly like yours.  

---

### Answer by username_6 on 2014-06-12. Score: 1

I was also looking for an elegant solution to server multiple domain from the same Craft instance and this is what I found.

The multiple domains documentation will assist your domain setup and is pretty easy: <http://buildwithcraft.com/docs/multi-environment-configs>

Where I got hung up is adding content which is specific to one domain. The only 'hacky' work around I could come up with was using rewrite rules (.htaccess, etc) to append the request with a url segment that could be targeted via routes.

example.com -> main site
example2.com -> landing page site. .htaccess rewrites to example2.com/lp/news

In the example above, I could also access the /lp/news from blog.example.com unless I want to manage conditionals in configs / .htaccess (for this domain, not this domain, etc).

At the end of the day, it's pretty clear Craft isn't intended for multiple sites and I don't recommend solutions that become a spaghetti mess to manage. If it's a landing page or two, I think using the combination of configs, routes and rewrite rule would do the trick...anything else I would look into a separate instance.


---

