stephenjpeck — 2013-12-02T22:58:53-05:00 — #1
I've looked everywhere for a solution, but I can't seem to find an answer.
I'm designing a website on my laptop running on my local server. When I include files within my code I must specify the root of my local server. When I upload the files to my web host the root is completely different. How do I fix my urls so that no matter where I'm accessing my code, whether locally or through a remote server, the url takes me where I need to go. I have something set up right now, but it seems sloppy.
I hope I explained it well.
kylewolfe — 2013-12-02T23:22:43-05:00 — #2
Welcome to the forums, Stephen!
Can you provide an example? Are you referring to php include urls or http request urls?
john_betong — 2013-12-03T01:28:14-05:00 — #3
// common, constants, config.php
defined('LOCALHOST') ?: define('LOCALHOST', 'localhost' == $_SERVER['SERVER_NAME']);
$XAMP = '/xampp/';
define('PATH_IMAGES', $XAMP. 'htdocs/afiles/images/');
define('PATH_THUMBS', $XAMP .'htdocs/asubs/subs-johns-jokes/thumb/');
define('PATH_IMAGES', FCPATH .'afiles/images/');
define('PATH_THUMBS', FCPATH .'subs/thumb/');
// works on both LOCALHOST AND REMOTE
echo '<img src="'. PATH_IMAGES .'my_image.jpg" style = "width:123px; " alt="#" />';