php root click link problem

Joined
12 Feb 2006
Posts
17,633
Location
Surrey
i'm trying to make my site link to pages from the root directory so that if the page is on level lower it will still link correctly to other pages.


this is all working fine, though with some difficulty because of using xampp, but the pages are able to include other pages.

the trouble i have is with links in that they link all the way back from the drive, and although the folders are correct Firefox cannot click the link popping up with a message about how it doesn't know what to do with the protocol g.

iirc from times before this will only be whilst developing the site on my pc but once online will be fine, however i don't want to have to re upload the pages every time i change them so would really like a fix for this.

thinking about it i think i'd need to change what the root directory is for xampp, currently htdocs. quick google is showing nothing, and also thinking that as htdocs is root but it still links from g://program files/my docuemtns etc, that changing it wont do anything.
 
also not a good idea to use $_SERVER['DOCUMENT_ROOT'] as it can be different on different servers - ie. one server might have it with the trailing / and one might not, meaning you'll have to go through and change everything that uses it.

well what i actually did was have all the files use $root, and then just include a file called start which defines what $root is, this way allowing for if something was different on the server from my pc then all i have to do is change the location of the start.php file to where document root links to, if that makes sense.

So basically, just give the path to your page relative to the docroot and add a slash to the front.

i must be doing something wrong as it still doesn't work.

what i basically have structure wise, names are just generic names for this example

Code:
index
contact
about
terms
etc
- memberFolder
     ---- profile
     ---- editProfile

- includesFolder
      ---- headerList
all the pages include the headerList page which lists the links that go in the header, so index, contact, about etc.

the trouble is then that when the headerList is included to profile.php it links to index in memberFolder which doesn't exist.

i have added the forward slash infront of the links, so they are linked like /index.php but it still doesn't work :confused:
 
Last edited:
edit

silly me it does work, just i was missing a folder that all this site is in, which is going to be a bit of a bugger later but will find a way around this.

thanks everyone
 
Last edited:
ok new problem kind of, using the / at the front when doing a php include doesn't start at the root directory like a link does.

i have a fix for this but it's not as pretty as just putting a forward slash so is there a solution for this?
 
Back
Top Bottom