<p>Hey Jeremy you can actually make siteUrl work using <a href="http://buildwithcraft.com/docs/multi-environment-configs" rel="nofollow">Multi-Enviroment Configs</a> and your general.php file will end up looking something like this.</p>

<pre><code>return array(
'*' =&gt; array(
    // ...
),

'example.dev' =&gt; array(
    // ...

    'environmentVariables' =&gt; array(
        'basePath' =&gt; '/users/brandon/Sites/example.dev/public/',
        'baseUrl'  =&gt; 'http://example.dev/',
    )
),

'example.com' =&gt; array(
    // ...

    'environmentVariables' =&gt; array(
        'basePath' =&gt; '/storage/av12345/www/public_html/',
        'baseUrl'  =&gt; 'http://example.com/',
    )
)
</code></pre>

<p>);</p>

CC BY-SA 3.0
2014-12-10T17:38:55.523Z
2014-12-10T17:38:55.523Z
Adam McCombs
<p>Not ideal in all situations, but one option is to simply set the Site URL to <code>/</code>:</p>

<p><a href="https://i.sstatic.net/N1RV5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/N1RV5.png" alt="Site URL"></a></p>

<p>This should make all your links relative, rather than absolute.</p>

CC BY-SA 3.0
2016-12-10T06:21:57.907Z
Hey Steve, I don't suppose you have the code that was in that link? It's a busted link now, making this answer kinda worthless. :(
Lindsey D
CC BY-SA 3.0
2016-12-11T11:29:11.907Z
Hey Lindsey, no code to speak of, just putting a forward slash into the Site URL field in General Settings. You may run into issues with this solution though, I'd recommend considering Adam's multi-environment set up as a better solution. The slash is a quick fix though and I do have a lot of sites running with that set up.
Steve Abraham
CC BY-SA 3.0
2016-12-12T22:52:41.457Z
Thanks Steve. I added the image directly to the answer, so we can be certain that it stays there forever. :)
Lindsey D
CC BY-SA 3.0
2014-12-10T19:03:20.293Z
2016-12-12T22:51:35.333Z
2016-12-12T22:51:35.333Z
Steve Abraham
<p>If you want to avoid the USB solution and just access your MAMP installation directly over your local network, you can also use a program called SquidMan (which is GUI wrapper for Squid) to set up a local network proxy. Here are <a href="http://benjaminrojas.net/view-mamp-virtual-hosts-on-your-ipad-and-iphone-over-the-local-network/" rel="nofollow">detailed instructions</a>, but the basics are:</p>

<ul>
<li>Download and launch SquidMan</li>
<li>Change the MAMP port to just use the default 80 to avoid many of the environment port config issues.</li>
<li>Set your MAMP hosts IP address to your local machine address (which should be available in the 'IP Address' dropdown under the hosts tab).</li>
<li>Start both MAMP server and Squid (via SquidMan)</li>
<li>Set the phone to use the squid proxy, then access the site normally through your phone using the MAMP address (i.e. <a href="http://sitename.craft.dev" rel="nofollow">http://sitename.craft.dev</a>)</li>
</ul>

CC BY-SA 3.0
2014-12-10T19:58:26.733Z
2014-12-11T03:20:49.333Z
2014-12-11T03:20:49.333Z
Douglas McDonald
<p>I'm developing a site using a mobile first approach, connecting the phone via USB and using Safari's Web Inspector on iOS8.</p>

<p>On my local machine, the url for all CSS, JS and href links is <code>http://localhost:8888/</code> (running MAMP) but on the phone it's my IP or <code>http://00.00.00.00:8888/</code></p>

<p>Right now, this issue is breaking the entire site when testing on a device. All links are broken. </p>

<p>How can I make the Craft variable <code>{{ siteUrl }}</code>... well variable? </p>

<templating><multi-environment><siteurl>
Making a dynamic {{ siteUrl }} for local mobile testing
# Making a dynamic {{ siteUrl }} for local mobile testing

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

I'm developing a site using a mobile first approach, connecting the phone via USB and using Safari's Web Inspector on iOS8.

On my local machine, the url for all CSS, JS and href links is `http://localhost:8888/` (running MAMP) but on the phone it's my IP or `http://00.00.00.00:8888/`

Right now, this issue is breaking the entire site when testing on a device. All links are broken.

How can I make the Craft variable `{{ siteUrl }}`... well variable?

**Tags:** templating, multi-environment, siteurl


---

## 3 answers

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

Hey Jeremy you can actually make siteUrl work using Multi-Enviroment Configs and your general.php file will end up looking something like this.
return array(
'*' => array(
    // ...
),

'example.dev' => array(
    // ...

    'environmentVariables' => array(
        'basePath' => '/users/brandon/Sites/example.dev/public/',
        'baseUrl'  => 'http://example.dev/',
    )
),

'example.com' => array(
    // ...

    'environmentVariables' => array(
        'basePath' => '/storage/av12345/www/public_html/',
        'baseUrl'  => 'http://example.com/',
    )
)

);


---

### Answer by username_2 on 2014-12-10. Score: 1

Not ideal in all situations, but one option is to simply set the Site URL to `/`:

[![Site URL](https://i.sstatic.net/N1RV5.png)](https://i.sstatic.net/N1RV5.png)

This should make all your links relative, rather than absolute.

> **Comments:**
> **username_3**: Hey Steve, I don't suppose you have the code that was in that link? It's a busted link now, making this answer kinda worthless. :(  
> **username_2**: Hey Lindsey, no code to speak of, just putting a forward slash into the Site URL field in General Settings. You may run into issues with this solution though, I'd recommend considering Adam's multi-environment set up as a better solution. The slash is a quick fix though and I do have a lot of sites running with that set up.  
> **username_3**: Thanks Steve. I added the image directly to the answer, so we can be certain that it stays there forever. :)  

---

### Answer by username_4 on 2014-12-10. Score: 0

If you want to avoid the USB solution and just access your MAMP installation directly over your local network, you can also use a program called SquidMan (which is GUI wrapper for Squid) to set up a local network proxy. Here are [detailed instructions](http://benjaminrojas.net/view-mamp-virtual-hosts-on-your-ipad-and-iphone-over-the-local-network/), but the basics are:

* Download and launch SquidMan
* Change the MAMP port to just use the default 80 to avoid many of the environment port config issues.
* Set your MAMP hosts IP address to your local machine address (which should be available in the 'IP Address' dropdown under the hosts tab).
* Start both MAMP server and Squid (via SquidMan)
* Set the phone to use the squid proxy, then access the site normally through your phone using the MAMP address (i.e. <http://sitename.craft.dev>)


---

