Difference between revisions of "Displaying Directory Contents In A CS Webpage"

 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Some CS users want to display the contents of a directory (located under their public_htm directory), however, CS has directory indexes disabled sitewide (to prevent people from inadvertently disclosing files by accident).
+
In some cases, you might want the CS webserver to display the contents of a directory (located under your <code>public_html</code> directory) when people view that directory in their web browser. This won't work automatically because we have disabled directory indexes to prevent people from accidentally disclosing files without intending to do so.
  
But, you can still display the contents of the directory using one of two methods:
+
You can still display the contents of a directory using one of the two following methods:
  
==Method 1: Using an ''index.html'' File==
+
== Method 1: Use an index.html File ==
  
You can create an index.html file that contains links to the contents of the directory.
+
You can create an <code>index.html</code> file that contains links to the contents of the directory.
  
==Method 2: Using a ''.htaccess'' File==
+
== Method 2: Use a .htaccess File ==
  
You can add a '''.htaccess''' file to the directory with the following contents:
+
You can add a '''<code>.htaccess</code>''' file (don't forget the leading dot) to the directory with the following contents:
  
 
<pre>
 
<pre>
    Options +Indexes
+
Options +Indexes
 
</pre>
 
</pre>
  
The settings in a '''.htaccess''' file apply to the directory it is in and to any of its subdirectories (recursively).
+
Make sure your <code>.htaccess</code> file has <code>604</code> permissions, just like [[File Permissions for Webpages|all other CS webpages need]].  If in doubt:
 +
 
 +
chmod 604 .htaccess
 +
 
 +
The settings in a <code>.htaccess</code> file apply to the directory it is in and to any of its subdirectories (recursively).
  
 
[[Category:Webpages and Webservices]]
 
[[Category:Webpages and Webservices]]

Latest revision as of 19:01, 10 May 2017

In some cases, you might want the CS webserver to display the contents of a directory (located under your public_html directory) when people view that directory in their web browser. This won't work automatically because we have disabled directory indexes to prevent people from accidentally disclosing files without intending to do so.

You can still display the contents of a directory using one of the two following methods:

Method 1: Use an index.html File

You can create an index.html file that contains links to the contents of the directory.

Method 2: Use a .htaccess File

You can add a .htaccess file (don't forget the leading dot) to the directory with the following contents:

Options +Indexes

Make sure your .htaccess file has 604 permissions, just like all other CS webpages need. If in doubt:

chmod 604 .htaccess

The settings in a .htaccess file apply to the directory it is in and to any of its subdirectories (recursively).