How do I make site links relative? 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 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?
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.

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' =&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/'
    )
),


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...


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.
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.
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.