Answers.Body: <p>I may be mistaken, but I feel like a standard multi-environment configuration should work for you in this situation... specifically the use of <a href="http://buildwithcraft.com/docs/multi-environment-configs#environment-specific-variables">environment-specific variables</a>.</p>
  
  <p>When you setup your multi-environment configuration, just set one up for each of your domain names. You would include something like this in your <strong>config/general.php</strong> file...</p>
  
  <pre><code>'my.first.domain' =&gt; array(
      'environmentVariables' =&gt; array(
          'siteUrl' =&gt; 'http://my.first.domain/'
      )
  ),
  'my.second.domain' =&gt; array(
      'environmentVariables' =&gt; array(
          'siteUrl' =&gt; 'http://my.second.domain/'
      )
  ),
  </code></pre>
  
  <p>Once you've got that setup, login to your Control Panel and go to:</p>
  
  <blockquote>
    <p>Settings > General</p>
  </blockquote>
  
  <p>Change the value of <strong>Site URL</strong> to be "{siteUrl}".</p>
  
  <p>Now, you can easily use any of these variations in your template:</p>
  
  <ul>
  <li><code>{{ siteUrl }}/contact-us</code></li>
  <li><code>url('contact-us')</code></li>
  <li><code>siteUrl('contact-us')</code></li>
  </ul>
  
  <hr>
  
  <p>It's a little tricky to explain the relationship between those three variations of "site url", but here's the gist of it...</p>
  
  <ol>
  <li><p>When you set an environment-specific variable in your config file, it can be parsed by Craft (in certain circumstances) with the syntax <code>{siteUrl}</code>. Note the single set of curly braces, and the lack of spaces between the variable name and the braces.</p></li>
  <li><p>The "Site URL" setting in your CP is capable of parsing out environment-specific variables. So when you put "{siteUrl}" in there, it represents whatever you put in your config file.</p></li>
  <li><p>Now, when you use <code>{{ siteUrl }}</code> in your templates, it uses whatever value is represented by the "Site URL" value in your CP. Since we just told that field to use the environment-specific variable, that's what will be parsed through to the front-end.</p></li>
  </ol>
  
  <p>In my example, I also mentioned <code>url()</code> and <code>siteUrl()</code>. These two functions will automatically prepend the "Site URL" value to whatever string you specify.</p>
  
  <p>The difference between the two only really matters <strong>if you're rendering a template in the Control Panel (using a plugin)</strong>. <code>url()</code> will prepend the <em>entire</em> site url, including the <code>/admin/</code> segment... meanwhile, <code>siteUrl()</code> will only prepend the <em>base</em> site url.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:15:19.070Z
Answers.Text: `{siteUrl}` with single curly braces (pt. 1) only work in the CP.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:17:59.253Z
Answers.Text: @ChristianSeelbach They can also be parsed out [via a plugin](http://buildwithcraft.com/docs/apis/configservice#parseEnvironmentString): `craft()->config->parseEnvironmentString($myString)`
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:21:57.433Z
Answers.Text: Possibly, but I think this isn't something @pumkincreative currently wants to do.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:24:21.123Z
Answers.Text: Agreed, I probably explained way more than I needed to in my answer. To be fair, he was trying to use an environment variable in his original example.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:26:28.573Z
Answers.Text: Brandon just posted [this Q&A](http://craftcms.stackexchange.com/questions/920/what-s-the-recommended-way-to-set-the-site-url) illustrating a different way to set the `{{ siteUrl }}` value... Perhaps that's a better method for @pumkincreative.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:26:30.477Z
Answers.Text: SiteUrl is very confusing, Lindsey. Brandon knows that and just posted a new Q&A about it.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:27:18.787Z
Answers.Text: This Brandon again... :D
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T21:28:10.220Z
Answers.Text: Lol, yup. He may have posted that in response to this thread. :)
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T13:10:21.307Z
Answers.Text: I just tried the set up in @LindseyD 's answer, but I'm not seeing the url outputted in templates - I just see `{siteUrl}` , the same as with my previous attempt, where I got `{host}` - any idea what I'm doing wrong? I am looking to change the URL presented by the `{{ entry.url }}` tag. Incidentally the server set-up I'm working with isn't recognising the .htaccess file at present, should this have any bearing.
Answers.UserDisplayName: pumkincreative
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T21:36:24.427Z
Answers.Text: @pumkincreative Since posting this yesterday, Brandon has posted a separate Q&A ([see here](http://craftcms.stackexchange.com/questions/920/what-s-the-recommended-way-to-set-the-site-url)) about a better way to set the site url value. The .htaccess won't have any effect on your source code.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T19:42:09.973Z
Answers.LastActivityDate: 2014-07-10T19:42:09.973Z
Answers.UserDisplayName: Lindsey D
Body: <p>To get around a temporary issue where two urls go to the same site, I wanted to set all my site links to be relative rather than using the full url. Looking through the Craft docs I found that it's <a href="http://buildwithcraft.com/docs/php-constants#craft-site-url" rel="nofollow">apparently possible</a> to place something like this in the index.php file:</p>
  
  <pre><code>define('CRAFT_SITE_URL', "http://{host}/");
  </code></pre>
  
  <p>However this didn't seem to work - I just get '{host}' appearing in all my links. Instead I set the site url as below, which has had the desired effect...</p>
  
  <pre><code>define('CRAFT_SITE_URL', "/");
  </code></pre>
  
  <p>...but is this a bad idea?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-13T17:16:31.877Z
Comments.Text: Why not use a mod rewrite rule?
Comments.UserDisplayName: Steve Adams
Tags: <config><url>
Title: How do I make site links relative?
ThreadText: # How do I make site links relative?
  
  (Asked by: username_0 on 2014-07-10)
  
  To get around a temporary issue where two urls go to the same site, I wanted to set all my site links to be relative rather than using the full url. Looking through the Craft docs I found that it's [apparently possible](http://buildwithcraft.com/docs/php-constants#craft-site-url) to place something like this in the index.php file:
  
  ```
  define('CRAFT_SITE_URL', "http://{host}/");
  
  ```
  
  However this didn't seem to work - I just get '{host}' appearing in all my links. Instead I set the site url as below, which has had the desired effect...
  
  ```
  define('CRAFT_SITE_URL', "/");
  
  ```
  
  ...but is this a bad idea?
  
  **Tags:** config, url
  
  > **Comments:**
  > **username_1**: Why not use a mod rewrite rule?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-07-10. Score: 4 | Accepted answer
  
  I may be mistaken, but I feel like a standard multi-environment configuration should work for you in this situation... specifically the use of [environment-specific variables](http://buildwithcraft.com/docs/multi-environment-configs#environment-specific-variables).
  
  When you setup your multi-environment configuration, just set one up for each of your domain names. You would include something like this in your **config/general.php** file...
  
  ```
  'my.first.domain' => array(
      'environmentVariables' => array(
          'siteUrl' => 'http://my.first.domain/'
      )
  ),
  'my.second.domain' => array(
      'environmentVariables' => array(
          'siteUrl' => 'http://my.second.domain/'
      )
  ),
  
  ```
  
  Once you've got that setup, login to your Control Panel and go to:
  
  > Settings > General
  
  Change the value of **Site URL** to be "{siteUrl}".
  
  Now, you can easily use any of these variations in your template:
  
  * `{{ siteUrl }}/contact-us`
  * `url('contact-us')`
  * `siteUrl('contact-us')`
  
  ---
  
  It's a little tricky to explain the relationship between those three variations of "site url", but here's the gist of it...
  
  1. When you set an environment-specific variable in your config file, it can be parsed by Craft (in certain circumstances) with the syntax `{siteUrl}`. Note the single set of curly braces, and the lack of spaces between the variable name and the braces.
  2. The "Site URL" setting in your CP is capable of parsing out environment-specific variables. So when you put "{siteUrl}" in there, it represents whatever you put in your config file.
  3. Now, when you use `{{ siteUrl }}` in your templates, it uses whatever value is represented by the "Site URL" value in your CP. Since we just told that field to use the environment-specific variable, that's what will be parsed through to the front-end.
  
  In my example, I also mentioned `url()` and `siteUrl()`. These two functions will automatically prepend the "Site URL" value to whatever string you specify.
  
  The difference between the two only really matters **if you're rendering a template in the Control Panel (using a plugin)**. `url()` will prepend the *entire* site url, including the `/admin/` segment... meanwhile, `siteUrl()` will only prepend the *base* site url.
  
  > **Comments:**
  > **username_3**: `{siteUrl}` with single curly braces (pt. 1) only work in the CP.  
  > **username_2**: @ChristianSeelbach They can also be parsed out [via a plugin](http://buildwithcraft.com/docs/apis/configservice#parseEnvironmentString): `craft()->config->parseEnvironmentString($myString)`  
  > **username_3**: Possibly, but I think this isn't something @username_0 currently wants to do.  
  > **username_2**: Agreed, I probably explained way more than I needed to in my answer. To be fair, he was trying to use an environment variable in his original example.  
  > **username_2**: Brandon just posted [this Q&A](http://craftcms.stackexchange.com/questions/920/what-s-the-recommended-way-to-set-the-site-url) illustrating a different way to set the `{{ siteUrl }}` value... Perhaps that's a better method for @username_0.  
  > **username_3**: SiteUrl is very confusing, username_2. Brandon knows that and just posted a new Q&A about it.  
  > **username_3**: This Brandon again... :D  
  > **username_2**: Lol, yup. He may have posted that in response to this thread. :)  
  > **username_0**: I just tried the set up in @username_2 's answer, but I'm not seeing the url outputted in templates - I just see `{siteUrl}` , the same as with my previous attempt, where I got `{host}` - any idea what I'm doing wrong? I am looking to change the URL presented by the `{{ entry.url }}` tag. Incidentally the server set-up I'm working with isn't recognising the .htaccess file at present, should this have any bearing.  
  > **username_2**: @username_0 Since posting this yesterday, Brandon has posted a separate Q&A ([see here](http://craftcms.stackexchange.com/questions/920/what-s-the-recommended-way-to-set-the-site-url)) about a better way to set the site url value. The .htaccess won't have any effect on your source code.  
  
  ---
  
  