phppathrelative-pathabsolute-pathphp-include

Including files from different folders after changing the document root


I am working on a project using WAMP. The vhost is configured like this:

<VirtualHost *:80>
   ServerName LearningPHP
   DocumentRoot c:/wamp64/www/learning_php/public/page/
   <Directory  "c:/wamp64/www/learning_php/public/page/">
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Require local
   </Directory>
</VirtualHost>

The Windows host file looks like this:

127.0.0.1       LearningPHP       # Project wamp64/www/learning_php
::1             LearningPHP       # Project wamp64/www/learning_php

The project structure looks like this:

enter image description here

I am trying to achieve this:

The problem I am experiencing:

I tried answers from similar questions using PHP constants, but I could not figure out what the issue is. For instance, I tried to add this <link rel="stylesheet" type="text/css" href="../public/css/style.css"> to the index.php under the page folder and it did not work. I also used the file location on disk, but no result.

I would really appreciate any help.


Solution

  • After consulting someone else on this issue I concluded (strictly referring to my own project) that:

    enter image description here

    The bottom line is that, as far as I could find out, folders outside the document root are not accessible to the browser (which makes sens keeping in mind the security reasons and how most of the PHP frameworks use this principle). However, the same file can be manipulated using server-side scripting.

    Please correct me, if I am mistaken.