CodeIgniter Forums
Differences referencing image from localhost and server - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Differences referencing image from localhost and server (/showthread.php?tid=49496)



Differences referencing image from localhost and server - El Forum - 02-22-2012

[eluser]Unknown[/eluser]
Hello all,

I just started using CI and am noticing a peculiarity referencing images. I hope somebody can help me out.

I'm referencing the image in /application/views/view_welcome.php:

If I use
Code:
/images/splash-logo.jpg
the image displays on the server, but not on my localhost.

If I use
Code:
images/splash-logo.jpg
it displays on localhost, but not on the server.

I have nothing in my .htaccess file.
$config['base_url'] = '';
$config['index_page'] = 'index.php';

Any ideas?


Differences referencing image from localhost and server - El Forum - 02-22-2012

[eluser]InsiteFX[/eluser]
Code:
<head>
    <base href="<?php echo base_url();?>" />
</head>

<body>
    images/splash-logo.jpg
</body>



Differences referencing image from localhost and server - El Forum - 02-25-2012

[eluser]Unknown[/eluser]
Thanks for replying, but I don't understand.

I'm referencing the image in a <div> like this:
Code:
background-image: url('/images/splash-logo.jpg');

If I use the '/' at the beginning it will display on the server, but not on my localhost.

If I don't use the '/' at the beginning it will display on my localhost, but not on the server.