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:
I am trying to achieve this:
learning_php/public/page/index.php
(I think I accomplished this through the vhost
configuration);page
directory (e.g. login
, profile_add
etc.) there are two files: index.php
and process.php
. I used this approach to organize my project better (I am not yet familiarized with the MVC
pattern);css
and js
folders the name of the files matches the name of the folder under the page
directory (e.g. page > profile_add
=> css/profile_add.css
or js/profile_add.js
). Later on I will merge all css
and js
files a page needs into individual files to limit the HTTP requests;The problem I am experiencing:
css
and js
files. I think this happens because I rewrite the DocumentRoot
in the vhost
configuration.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.
After consulting someone else on this issue I concluded (strictly referring to my own project) that:
document root
specified in the vhost
configuration. An alternative is to point the document root
to learning_php/public/
and structure the project this way: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.