Using Apache to host files in multiple HDDs - apache

I have Windows version of XAMPP installed in C:\xampp.
All works well, however I am building a Netflix clone and all of my material (Shows/Movies/etc) are located in external HDDs (e.g.: E:\ and F:\).
Is there a way to keep site in C:\ while having access to E:\ and F:\ ? Basically all I need is to provide video src full path to E:\movie.mkv or F:\movie.mkv but when I do it now - blank screen is shown.
I am only aware of solution where I could merge two HDDs into one (Dynamic HDD) which would then share same drive letter and change DocumentRoot to that letter. I would like to avoid such setup however.

If you have something "streaming" the file to the enduser, there's no problem: your php,jsp or whatever you're using just need to have access to the file, regardless where it is, reand and stream it.
If you're just planning to show the content of the folder itself, you can create an Alias to each root folder. You can refer to the official documentation for the details: https://httpd.apache.org/docs/2.4/mod/mod_alias.html

Thanks for setting me on the right path (no pun intended). For those who need the answer:
httpd.conf:
Alias /disk1 "E:"
<Directory "E:">
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
Alias /disk2 "F:"
<Directory "F:">
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>

Related

Setting sabre/dav to have root directory outside of apache web root

I am trying to set up a WebDav server using sabre/dav. I got it set up and running and as long as I serve up files form with in the web server root (like /var/www/mydocs) I can access them in read-write mode. However, when I move sabre’s root directory to be like /mnt/mydocs I can only access them in read only mode. I do not think it is file permissions because I set them up the same both places and gave apache full access to both. I think it might be apache directory access directives but I have not found any combination that works. The last thing I tried in the apache config file was something like this.
<Directory “/mnt/mydocs”>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
Any ideas? Thanks for your help.

Options +Indexes will not show filenames

How can I show file names in the directory listing on apache server.
I am using
Options +Indexes
I have also tried
Options Indexes FollowSymLinks
in the root but I am not able to see file names only an empty structure
There are 4-5 files of different names and extension available in the folder.
If you're unable to generate auto index even after dabbling with file permissions; it is generally all thanks to IndexIgnore directive.
Check your server settings, going one step above from the current htaccess at a time. See where you encounter it.

How to make $_SERVER['DOCUMENT_ROOT'] reference to alias directory path and NOT wamp default path?

I currently have my WAMP installation at:
C:/wamp/www/
My issue:
When calling $_SERVER['DOCUMENT_ROOT']; from localhost/projectname1/test.php - this outputs:
C:/wamp/www/
This is no good since path in my scripts will be wrong then. I this case I want Document root to output (which is my alias path for this dummy project):
C:\Users\SGS\Google Drive\_Work\projectname1\html/
All my working files are on google drive, so for each project I create an Apache alias, that points to the direct path of the project located on google drive folder.
Example of an alias created - projectname1.conf:
Alias /projectname1/ "C:\Users\SGS\Google Drive\_Work\projectname1\html/"
<Directory "C:\Users\SGS\Google Drive\_Work\projectname1\html/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
This allow me to call the project with localhost/projectname1/
How do I get my document?
I think you would be better creating a Virtual host for each of your projects.
HowTo setup Virtual Hosts
The problem with SCRIPT_NAME is that it is not static because it is based on the name of current executing script. Before Apache 2.3.x becomes popularly adopted so that we can use CONTEXT_PREFIX variable, I'm afraid there's no solution.

Apache httpd.conf restrict access to parent using Alias

I have an Alias for a directory
Alias /out /myData/all
<Directory /myData/all >
Options Indexes MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
myData/all has many subdirectories of different projects. When someone accesses host/out/project01 through a direct link, I would like to restrict their ability to to click Parent Directory and see all project folders under out. Is this possible with the alias?
If you're talking about something like:
http://example.com/out/project01/..
^^--- "up a level" link
then the actual requested page would be
http://example.com/out/
which is aliased to the /myData/all directory. Since that directory has indexes enabled (Options Indexes) they could browse all the projects.
Either turn off indexes, or move your aliases down a level:
Alias /out /myData/all/project01
so that moving up a level:
http://example.com/out/..
simply takes you to
http://example.com/

Folders redirection in apache

I have user files stored in a folder outside apache's documents root e.g. My project is in /var/www/ProjectName/ and the files are in local drive(D:\users).
I want to be able to link to those files from within my project. i am using symfony(php framework).
I trying to change the setting in apache like this, But no luck
Alias /users/ "D:\users"
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
You have to update that in your httpd.conf or in your specified {name of your vhost}.conf.
Alias /users/ D:\users
Be sure to check the error log to see where here Apache tries to find the files.