Options +Indexes will not show filenames - apache

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.

Related

.htaccess is not being read using XAMPP

I cant figure out why the .htaccess file is not being read. I am using XAMPP
Here is the httpd.conf file
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options None
AllowOverride All
Require all granted
</Directory>
I dont want content listing enabled except for one folder called photos.
so inside the photos directory inside htdocs- using notepad i created a .htaccess file and included
#Allow the listing of folder content
Options All
This did not work and the error log shows:
Cannot serve directory C:/xampp/htdocs/photos/: No matching DirectoryIndex (home.php,home.html,home.htm,index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
I also added rubbish to the beginning of the access file to see if it would reproduce an error but all it says is 403 forbidden.
Other things i tried was
#Allow the listing of folder content
Options Indexes
basically, for every folder there should be no content listing except for the photos folder which is why i created a .htaccess file and placed it inside the photo folders. (it must be a .htaccess)
any ideas why this is not working?
To anyone who comes across this needing help - I figured it out.
notepad was saving it as .htaccess.txt even after selecting 'All Files'
To fix this used brackets (you can use another other software like notepad++) and saved it under .htaccess and that worked.

Using Apache to host files in multiple HDDs

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>

How to troubleshoot index forbidden by Options directive error

I am seeing the title message in the error log where I am trying to list files in a directory. I know it has to do with no index file in the driectory, but I just need to list files. I have this line in my httpd.conf file:
Options Indexes FollowSymLinks
Can someone suggest a way to enable file listing in a directory. Thanks
Check for other occurrences of the Options keyword, and take note of where they are. There's probably one somewhere in a matching <Directory> configuration block. grep -Ri Options /etc/httpd may be of help.
It's recommended to only allow Indexes in directories where you actually intend to allow directory listings, so it may be a good idea to add your own <Directory> block.

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.

How can I get apache to list a folders contents?

How can I get Apache to display the contents of my folder and provide links to them? Similar to http://www.kernel.org/pub/linux/?
I don't have access to the Apache configuration, so I'm looking for something in the way of .htaccess or something I can do in just my home folder.
You have to use the option Indexes in the Apache configuration.
For instance, in the .htaccess file for your directory (if you can use those, and have sufficient privileges), you could put :
Options +Indexes
This functionality is provided by mod_autoindex, which has lots of options to allow fine-tuning of the generated output, btw
To get this working, that module must be loaded, and to be able to activate the option in an .htaccess file, you will need the admin of the server to give you some privileges (with the AllowOverride directive in the Apache's main config file, if I remember correctly -- well, your admin should know that better than me anyway ^^ )