Pathing using ./, ../, .. - what do they exactly mean for my view files? <p>I always worry about pathing issues when I move my website into subfolders because I don't know how to handle it with PHP.</p> <p>I want to learn this with an example because I can easily learn it by looking at examples.</p> <p>Let's say I have a website running at this directory: <code>httpdocs/development/subfolder/myWebsite/index.php</code></p> <p>By default, PHP would run <code>httpdocs/index.php</code>, so it is the root path but my website runs in a subfolder.</p> <p>In my website's index.php, (so we're in a subfolder) how can I ensure I point correct folders?</p> <pre><code>&lt;img src="images/1.jpg"&gt; // Does no dot means root path? &lt;img src="./images/1.jpg"&gt; //Does ./ means which_directory_our_php_page_currently_in/images? &lt;a href="./"&gt; // Points /subfolder/myWebsite/ or httpdocs/ ? &lt;a href=".."&gt; //Same as above, but no front slash. &lt;a href=""&gt; //Same as above </code></pre> <p>I don't want to make a definition or a const to track it with PHP and change it whenever I move my files. Like:</p> <pre><code>define('SITE_PATH', './development/subfolder/myWebsite/'); </code></pre> <p>Especially when it comes into <code>DIRECTORY_SEPARATOR</code>, things only get more confusing.</p> <p>I would like to know how to handle it with PHP professionally; what is the difference between <code></code> and <code>./</code>; lastly what does <code>..</code> mean without forward slash.</p> <p>Thank you.</p>