Forum Moderators: coopster

Message Too Old, No Replies

How to do correct path?

         

toplisek

6:39 am on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have many folders and subfolders on server. As I would like to add code on each page to detect server URL, I need help with this.

Code is: $_PATH1="http://" . $_SERVER['HTTP_HOST']."/";
Why I have to add on link for images also / that it will work as it is already there / in

Link is like. <img src="<?=$_PATH1?>images/myimage.jpg" ></a>

Scally_Ally

8:13 am on May 16, 2007 (gmt 0)

10+ Year Member



Is that not working?
It should work.

The way i would usually do it is to have a config file that gets included in every page, and declare them as global variables. eg,

define("SITEPATH", "http://www.example.com/");
define("DOCROOT", "/home/site/path/to/your/site/");

Then do like you are doing,
<img src="<?php echo SITEPATH;?>images/myimage.jpg" >

Ally