Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T10:45:19.520Z
Answers.Text: 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.
Answers.UserDisplayName: Steve Adams
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-20T18:04:01.513Z
Answers.Text: Found the multiple subdomain feature extremely useful for making a dev.site.
Answers.UserDisplayName: Matteo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T03:20:32.153Z
Answers.LastActivityDate: 2014-06-12T03:20:32.153Z
Answers.UserDisplayName: Luke Holder
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T03:24:02.230Z
Answers.Text: 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.
Answers.UserDisplayName: Luke Holder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T13:31:36.293Z
Answers.Text: My mistake. I misunderstood the question. :)
Answers.UserDisplayName: tnypxl
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-09T16:40:22.037Z
Answers.Text: @tynpxl, I found your answer very helpful. My interpretation of the original question was exactly like yours.
Answers.UserDisplayName: PKHunter
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T01:25:51.807Z
Answers.LastActivityDate: 2014-06-12T01:25:51.807Z
Answers.UserDisplayName: tnypxl
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T15:55:37.457Z
Answers.LastActivityDate: 2014-06-12T15:55:37.457Z
Answers.UserDisplayName: nateiler
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T07:07:03.537Z
Answers.Text: Simon, how do I add the subdomain to automatically generated links from a (redactor) rich text field? Is this possible?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T19:01:48.050Z
Answers.Text: Short of manually editing the links I don't know of any good options.
Answers.UserDisplayName: Simon Kuran
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-16T07:50:19.360Z
Answers.Text: try putting {siteUrl} into the craft config? http://glui.me/?i=ao3ste0jh061kdj/2014-06-16_at_3.49_pm.png/
Answers.UserDisplayName: Luke Holder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-16T21:00:20.517Z
Answers.Text: I don't see what that would do as Craft would still have no idea what sections load at what URLs.
Answers.UserDisplayName: Simon Kuran
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2014-06-12T06:48:26.863Z
Answers.LastActivityDate: 2018-06-06T05:24:23.733Z
Answers.LastEditDate: 2018-06-06T05:24:23.733Z
Answers.UserDisplayName: Simon Kuran
Body: <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>
  
Tags: <config><server><multi-site><deployment>
Title: Can I run one Craft install on multiple domains and/or subdomains?
ThreadText: # 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](https://docs.craftcms.com/v3/sites.html) to the official docs and [here's a link](https://craftcms.stackexchange.com/questions/19601/multi-site-setup-in-craft3) to another question with more resources.
  
  **Old answer for Craft 1 & 2**
  
  Credit to @username_1 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**: username_0, 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.
  
  
  ---
  
  