Results 1 to 5 of 5
Let's say I have an application installed that needs Apache to actually display it on the browser. Before running the application in the browser, the first step is to make ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-01-2012 #1
- Join Date
- Dec 2009
Directory listing for Apache web server
Before running the application in the browser, the first step is to make sure the Apache web server is running (the browser is enabled), and then make sure whether or not the directory listing can be viewed when typing :
(In this example, my Directory Index points to index.php)
What if I do not want a particular directory to be listed in the browser?
Do I edit the httpd.conf file in the "Directory" section e.g :
<Directory "/path/to/directory"> ' ' ' ' ' </Directory>
or is there any other proper way??
Thanks in advance,
- 12-03-2012 #2
In Apache the directory listing is done in 2 ways using 2 directives/modules.
1. using the DirectoryIndex directive from the mod_dir module:
Using this option the server will only show the index for the folders with the "DirectoryIndex <file.html>" directive and the file.html file inside. (The files can have any name you want.)
DirectoryIndex index.php #Apache will search for index.php in /path/to/directory/ and display it's content if found
2. using the Options +Indexes from the mod_autoindex module.
Using this module, Indexes are generated automatically for all the folders inside.
To disable this for a particular folder use this:
Options -Indexes # Apache won't generate autoindexes for /path/to/directory/
Also be advised that both modules can work together. In this case the server will search for index.php, index.html, index.htm files (files you mentioned in httpd.conf) and if none are found mod_autoindex is started.
So, first you should choose one of the above methods (or both) and decide how will you restrict listing for the particular folder after.
I hope this answered your question.
Last edited by srj; 12-03-2012 at 12:26 PM.
- 12-03-2012 #3
In your example the URL is directly to the index file.
Be advised that Apache will provide index files only if the URL ends with "/" and the last part is a folder. Ex: http://hostaddress/folder/
If "/" is not used "mod_dir" directive will send a redirect to the client. The redirect will contain the full path "http://hostaddress/folder/" but if the server is not configured correctly or if mod_dir is not loaded this won't work.
Remeber to end the URL with "/" to let the server know it's a folder.
- 12-03-2012 #4
- Join Date
- Dec 2009
Thanks for the reply!
But may I know where the mod_dir or mod_autoindex modules are located??
For my configuration, the line DirectoryIndex index.php was in the file
httpd-dms.conf (another file). This file is a file to configure paths and other options for the application I was to use in the browser.
and path for the apache root directory was listed in httpd.conf.
So are these 2 files where these modules are located?
- 12-03-2012 #5
The modules are located where your Apache server was installed, usually in a subfolder called "modules" and their extensions is ".so".
If you installed the server using a pre-compiled package most likely all the modules are already included. (both mod_dir and mod_autoindex).
You must understand that Apache is a modular server and certain features are only available with the help of those extra modules. For example, the "DirectoryIndex" directive you found in your configuration file won't be available without the mod_dir module.
The modules are either compiled within your httpd executable (all the modules are built-in, but I don't think so) or loaded from your configuration file with the "loadmodule" directive. You can say a module it's a ".dll" file from the world of Windows. (If this analogy helps you)
Look for the "LoadModule" directive within your httpd.conf to see if they are loaded from there and disable/enable them as you wish. I don't know how to use the application you mentioned but from what it looks like the "httpd-dms.conf" is working with Apache.
If you really want to start this server up I suggest you read the user guides (Documentation: Apache HTTP Server - The Apache HTTP Server Project) or guides from any other sources (but please make sure you read the correct guides for your version) and reply back if you have other questions.