-
Apache Config File
So I want to have a feature on my website where I will be able to access my personal files from the website. Currently I am using .htaccess to prevent just anyone from viewing the file browser, but I will probably change that to some different method in the future. (Since apparently .htaccess is supposed to be really taboo)
There were two problem I needed to overcome. First, I basically wanted to share my entire second hard drive with limited access. So I added this line to the Apache configuration file :
Alias /media/ F:/
This allows me to route to the F drive by going to mywebsite.com/media/
Now I just needed to set up the directory permissions. I had this in the config file:
SetEnvIf PHP_AUTH_USER "USER" let_me_in
<Directory "F:/">
Options All
AllowOverride All
Order deny,allow
Deny from All
Allow from env=let_me_in
</Directory>
Even after I have logged in with .htaccess as the USER, it does not permit me to open the file. I thought that maybe the problem was outside of Apache, so I removed the deny and allow lines I have in there and I added, "Allow from All". I was then able to connect to the drive, but so was everyone else in the world. I also tried declaring my own enviornmental variable called "MEDIA_ACCESS" in the page that would call the files off of the drive and then I tried:
SetEnvIf MEDIA_ACCESS 1 let_me_in
<Directory "F:/">
Options All
AllowOverride All
Order deny,allow
Deny from All
Allow from env=let_me_in
</Directory>
and,
<Directory "F:/">
Options All
AllowOverride All
Order deny,allow
Deny from All
Allow from env=MEDIA_ACCESS
</Directory>
Neither of these worked. Does anyone have any idea what I could be doing wrong?
-
Nevermind, I got it working. In case anyone else runs into this issue here is what I added to the Apache config file:
# ADD MEDIA DRIVE TO SHARED FOLDER
# ONLY ALLOW ACCESS FROM LOCAL HOST LINKS
Alias /media/ F:/
SetEnvIf Referer "^http://www.mywebpage.com/" let_me_in
<Directory "F:/">
Options All
AllowOverride None
Order deny,allow
Deny from All
Allow from env=let_me_in
</Directory>