Answers.Body: <p>I know you asked for a way to do this without using a redirect, but if it's handled server-side via twig, it would be transparent and virtually instantaneous:</p>
  
  <pre><code>{% if siteUrl == "http://subdomain.site.com/"  %}
      {% redirect 'subdomainFolder' %}
  {% endif %}
  </code></pre>
  
  <p>You could also redefine the default 'index' template using <code>indexTemplateFilenames</code> in your config file's multi-environment return array for that subdomain, but that would affect all index files for that subdomain in every uri and be pretty extreme:</p>
  
  <pre><code>/**
   * The template filenames Craft will look for within a directory to represent the directory’s “index” template when
   * matching a template path to a file on the front end.
   */
  'indexTemplateFilenames' =&gt; array('index'),
  </code></pre>
  
  <p>As far as I know, I don't believe you can specify a full url in custom routes, only uri patterns — but perhaps someone else with more experience with this can add-in. And there may be some other options as well, that I don't know about.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-13T21:28:55.287Z
Answers.Text: Thanks Douglas - This is totally valid but I'd like to do it without a redirect if possible to retain tracking information , origin source etc. I'm not sure how much of this would remain if we redirect from the homepage. Functionally this works perfectly, we just have an odd use case.
Answers.UserDisplayName: Adam McCombs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-13T21:38:44.380Z
Answers.Text: Understood... but my understanding is that all requests are getting routed through craft anyway via a similar method (i.e. every request that craft manages is essentially a 404 redirect). I'm not sure there is much of a difference, whether it's initiated by twig in a template or via a craft service method — it's all a server side redirect. This shouldn't affect tracking information or origin source at all. I'm curious to see if anyone know any other options though.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-13T21:26:40.473Z
Answers.LastActivityDate: 2014-11-13T21:26:40.473Z
Answers.UserDisplayName: Douglas McDonald
Answers.Body: <p>For this example we have two domains:</p>
  
  <pre><code>http://www.example.com
  http://subdomain.example.com
  </code></pre>
  
  <p>To use different templates for the subdomain, we can accomplished this with these steps:</p>
  
  <p>1) Setup subdomain to point to a different directory on your server:</p>
  
  <pre><code>Domain: /home/wherever/public_html
  Sub-domain: /home/wherever/public_html_subdomain
  </code></pre>
  
  <p>2) Copy your index.php file over to your new subdomain directory and update the <code>CRAFT_TEMPLATES_PATH</code> variable to point to the location you want to have your templates.  In this example, both template folders are above web root.</p>
  
  <pre><code>// index.php for domain
  define('CRAFT_TEMPLATES_PATH', realpath(dirname(__FILE__) . "/../templates").'/');
  
  // index.php for subdomain
  define('CRAFT_TEMPLATES_PATH', realpath(dirname(__FILE__) . "/../templates_subdomain").'/');
  </code></pre>
  
  <p>Your template folders now look like:</p>
  
  <pre><code>/home/wherever/public_html
  /home/wherever/public_html_subdomain
  /home/wherever/templates
  /home/wherever/templates_subdomain
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-14T22:09:20.553Z
Answers.LastActivityDate: 2014-11-14T22:09:20.553Z
Answers.UserDisplayName: Ben Parizek
Body: <p>We are looking for a way to route a subdomain to a specific template to use as a landing page.</p>
  
  <p>Is there a way to do this without routing through index.html and redirecting to the specified template folder and file?</p>
  
  <p>I can confirm that using the redirect <strong>does</strong> lose some of the user information, tracking codes etc. However it does retain the referral url from the 3rd party site.</p>
  
Tags: <templating><routing><subdomain>
Title: Is it possible to route a subdomain to specific template group?
ThreadText: # Is it possible to route a subdomain to specific template group?
  
  (Asked by: username_0 on 2014-11-13)
  
  We are looking for a way to route a subdomain to a specific template to use as a landing page.
  
  Is there a way to do this without routing through index.html and redirecting to the specified template folder and file?
  
  I can confirm that using the redirect **does** lose some of the user information, tracking codes etc. However it does retain the referral url from the 3rd party site.
  
  **Tags:** templating, routing, subdomain
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-11-14. Score: 9 | Accepted answer
  
  For this example we have two domains:
  
  ```
  http://www.example.com
  http://subdomain.example.com
  
  ```
  
  To use different templates for the subdomain, we can accomplished this with these steps:
  
  1) Setup subdomain to point to a different directory on your server:
  
  ```
  Domain: /home/wherever/public_html
  Sub-domain: /home/wherever/public_html_subdomain
  
  ```
  
  2) Copy your index.php file over to your new subdomain directory and update the `CRAFT_TEMPLATES_PATH` variable to point to the location you want to have your templates. In this example, both template folders are above web root.
  
  ```
  // index.php for domain
  define('CRAFT_TEMPLATES_PATH', realpath(dirname(__FILE__) . "/../templates").'/');
  
  // index.php for subdomain
  define('CRAFT_TEMPLATES_PATH', realpath(dirname(__FILE__) . "/../templates_subdomain").'/');
  
  ```
  
  Your template folders now look like:
  
  ```
  /home/wherever/public_html
  /home/wherever/public_html_subdomain
  /home/wherever/templates
  /home/wherever/templates_subdomain
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2014-11-13. Score: 2
  
  I know you asked for a way to do this without using a redirect, but if it's handled server-side via twig, it would be transparent and virtually instantaneous:
  
  ```
  {% if siteUrl == "http://subdomain.site.com/"  %}
      {% redirect 'subdomainFolder' %}
  {% endif %}
  
  ```
  
  You could also redefine the default 'index' template using `indexTemplateFilenames` in your config file's multi-environment return array for that subdomain, but that would affect all index files for that subdomain in every uri and be pretty extreme:
  
  ```
  /**
   * The template filenames Craft will look for within a directory to represent the directory’s “index” template when
   * matching a template path to a file on the front end.
   */
  'indexTemplateFilenames' => array('index'),
  
  ```
  
  As far as I know, I don't believe you can specify a full url in custom routes, only uri patterns — but perhaps someone else with more experience with this can add-in. And there may be some other options as well, that I don't know about.
  
  > **Comments:**
  > **username_0**: Thanks username_1 - This is totally valid but I'd like to do it without a redirect if possible to retain tracking information , origin source etc. I'm not sure how much of this would remain if we redirect from the homepage. Functionally this works perfectly, we just have an odd use case.  
  > **username_1**: Understood... but my understanding is that all requests are getting routed through craft anyway via a similar method (i.e. every request that craft manages is essentially a 404 redirect). I'm not sure there is much of a difference, whether it's initiated by twig in a template or via a craft service method — it's all a server side redirect. This shouldn't affect tracking information or origin source at all. I'm curious to see if anyone know any other options though.  
  
  ---
  
  