Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP; howto use absolute paths

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28020
    quelake
    Member

    Hey all,

    taking my first steps in PHP, I tried to create a website that support 2 languages. The pages of the english version are located at the root of the domain (just like any other site), while I created a subfolder "/NL" for the dutch version of the site.

    I then created to headers (header_nl and header_en) and placed them in a folder "includes". So my site looks something like this;

    /root:
    index.php
    …etc
    /images/
    /css/
    /includes/
    header_nl
    header_en
    /NL/
    index_dutch.php
    …etc.

    My header includes both have the <head> portion etc included in them, and so reference to the CSS folder for markup. My problem is that I can’t get the NL portion of the site to link correctly to my CSS files! I have no idea what I am doing wrong at this point. I am used to link to absolute paths using "../somefolder/somefile.css", but that does not work in this case (using ../css/style.css in my header_nl).

    can someone point out where this goes wrong, PHP-wise? Or maybe point me in the direction of a good tutorial on this? I have looked through the forums, and googled (/BING’ed if you’re a google-hater ;) ) on absolute PHP path tutorials, but to no avail thushar.

    #71804
    quelake
    Member

    Hey Rob,

    I am at work right now, so I do not have access to my temporary site. It is not online right now. I will get on it this evening.

    (and no, I did not use Bing, but I wanted to keep the google-haters off my back! :P)

    <<<BING!!>>> Say it like it’s fun!! :P

    #71839
    quelake
    Member

    Well, as soon as I got home I’ve been fiddling with the settings a bit more, and…

    I think I got it?

    At first I used a construction such as below, and used $root_nl to link to the root-folder (I found this method for absolute paths in a tutorial). This did not work well in my case.

    <?php
    $root_nl = realpath($_SERVER["DOCUMENT_ROOT"]);
    ?>

    It turned out to be much simpler I gues…Am I right in assuming that any file that is referenced to beginning with a "/" is approached from the root directory, while any file that is in the form of, for example "images/some/file.php" is a relative path, depending on the current directory?

    I have put up some files on a temp site; you can go here if you’re interested in seeing what I’ve made of it.

    http://www.dualiciouz.com/temp/index.php
    http://www.dualiciouz.com/temp/nl/indexnl.php
    http://www.dualiciouz.com/temp/includes/header_nl.php
    http://www.dualiciouz.com/temp/includes/header_en.php

    (that are undoubtedly some typo’s in there, but bare with me) I have uploaded the bare essentials; CSS file and just one image to see if the link is correct. So if you’re thinking the site looks incredibly ugly; you’re right! ;)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.