Difference between revisions of "Displaying Directory Contents In A CS Webpage"
(14 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | 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. | |
− | + | You can still display the contents of a directory using one of the two following methods: | |
− | ==Method 1: | + | == 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: | + | == 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 | |
</pre> | </pre> | ||
− | + | 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: | |
− | [[Category: | + | 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]] |
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).