I am sure that this is a repost but I cannot find a question the same as what I want to find out. Essentially, whenever I am working offline, all URIs that I use across the site refer to offline locations eg 127.0.0.1/home.html however, when I go to upload the site, these URIs need to be changed to their equivalents eg example.com/home.html and I either need to go through all of the pages and update these references or use some php to insert the correct address at every point where an address is used. At the minute I am using something like this:
Top of every page:
<?php $offline = false; ?>
Link:
<a href="<?php echo ($offline ? '127.0.0.1' : 'example.com'); ?>/home.html">Home</a>
But this seems like a poor way to achieve something which should be relatively simple. What is the standard way of keeping these references up to date. I considered using relative links everywhere but that proved to have problems (for example view includes don't work correctly) and I tried setting the base
href
to the homepage but that threw up other problems.
Any suggestions would be very much appreciated. Thanks.