Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My web app is running after being deployed on Apache2 (local OS is Ubuntu 18.04 LTS). There is a plethora of controller-related urls like localhost://get_id/<id> or localhost://delete/<id>. Whenever I enter them into search mask, page of my we site appears here, well. What brings me into misunderstanding is a problem of opening any local file inside Apache root directory (/var/www/html) instead of getting content by urls. To be more specific: I have file `sample.txt`> within directory /var/www/html/samples. Now I need to display what this file contains but after typing localhost://samples/sample.txt (suggesting that localhost file source is just /var/www/html) it fails to show anything like sample.txt though Not found.
Virtual host configurations are defined as below:
<VirtualHost *:80>
    
            ErrorLog ${APACHE_LOG_DIR}/site-error.log
            CustomLog ${APACHE_LOG_DIR}/site-access.log combined
    
            <Location />
             ProxyPass unix:/var/www/html/site/site.sock|http://127.0.0.1/
             ProxyPassReverse unix:/var/www/html/site/site.sock|http://127.0.0.1/
            </Location>
</VirtualHost>


I see clear it's a case of missing configuration for a virtual host - which exactly? I was looking for any earlier posts, questions and answers (that's pretty simple issue, so it was responded in the past, I'm sure), but without success. Let me note I'm a newbie to server technologies like Apache, my experience doesn't enable me to solve that matter myself so far. So, how do I want to implement file paths instead of web site url, essentially? Any pointer will be kindly appreciated.

What I have tried:

I was looking for any earlier posts, questions and answers (that's pretty simple issue, so it was responded in the past, I'm sure), but without success.
Posted
Updated 11-Jun-20 15:03pm

1 solution

This may help Mapping URLs to Filesystem Locations - Apache HTTP Server Version 2.5[^]

What you have to realise is there must be 'protection' between the 'Web Layer' and the Local file system - imagine if on a Windows system a user could cause damage to "C:\Program Files" and a myriad of other such directories - hence the access levels and 'mappings' for local -> web

Hopefully that link gives you a way of doing it -
Quote:
Files Outside the DocumentRoot
for instance
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900