Htaccess - Directory Listing: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
 
 
Zeile 5: Zeile 5:
 
When a web browser is pointed to a directory on your web site which does not have an index.html file in it, the files in that directory can be listed on a web page.
 
When a web browser is pointed to a directory on your web site which does not have an index.html file in it, the files in that directory can be listed on a web page.
  
1. Enable/Disable Directory Listing
+
 
 +
== 1. Enable/Disable Directory Listing ==
 +
 
  
 
To have the web server produce a list of files for such directories, use the below line in your .htaccess.
 
To have the web server produce a list of files for such directories, use the below line in your .htaccess.
  
Options +Indexes
+
Options +Indexes
  
 
To have an error (403) returned instead, use this line.
 
To have an error (403) returned instead, use this line.
  
Options -Indexes
+
Options -Indexes
 +
 
 +
 
 +
== 2. Listing Style ==
  
2. Listing Style
 
  
 
Either a basic list of files can be shown, or a 'fancy' list including icons, file size, modification date and more.
 
Either a basic list of files can be shown, or a 'fancy' list including icons, file size, modification date and more.
  
IndexOptions +FancyIndexing
+
IndexOptions +FancyIndexing
  
 
Add this to your .htaccess file to use the 'fancy' style.
 
Add this to your .htaccess file to use the 'fancy' style.
  
IndexOptions -FancyIndexing
+
IndexOptions -FancyIndexing
  
 
Use the above line if you prefer a more basic file list.
 
Use the above line if you prefer a more basic file list.
  
3. Ignore Files
+
 
 +
== 3. Ignore Files ==
 +
 
  
 
Let's say you have a directory with .jpg, .gif and .png image files. You only want the .png files to show in the directory listings. Add this line to your .htaccess.
 
Let's say you have a directory with .jpg, .gif and .png image files. You only want the .png files to show in the directory listings. Add this line to your .htaccess.
  
IndexIgnore *.gif *.jpg
+
IndexIgnore *.gif *.jpg
  
 
The web server now ignores the .gif and .jpg files.
 
The web server now ignores the .gif and .jpg files.
  
4. Modify Index File
+
 
 +
== 4. Modify Index File ==
 +
 
  
 
Maybe you don't want a list of the files, you want a specific file to be shown instead. You could upload an index.html file in this directory. There is another way.
 
Maybe you don't want a list of the files, you want a specific file to be shown instead. You could upload an index.html file in this directory. There is another way.
  
DirectoryIndex myfile.html
+
DirectoryIndex myfile.html
  
 
Instead of listing the files, web page myfile.html will now be shown for this directory and its subdirectories.
 
Instead of listing the files, web page myfile.html will now be shown for this directory and its subdirectories.

Aktuelle Version vom 3. Juli 2007, 13:04 Uhr

Tutorial aus http://www.clockwatchers.com/htaccess_dir.html Datum des Zugriffs: 3.7.2007

.htaccess Tutorial - Directory Listing

When a web browser is pointed to a directory on your web site which does not have an index.html file in it, the files in that directory can be listed on a web page.


1. Enable/Disable Directory Listing[Bearbeiten]

To have the web server produce a list of files for such directories, use the below line in your .htaccess.

Options +Indexes

To have an error (403) returned instead, use this line.

Options -Indexes


2. Listing Style[Bearbeiten]

Either a basic list of files can be shown, or a 'fancy' list including icons, file size, modification date and more.

IndexOptions +FancyIndexing

Add this to your .htaccess file to use the 'fancy' style.

IndexOptions -FancyIndexing

Use the above line if you prefer a more basic file list.


3. Ignore Files[Bearbeiten]

Let's say you have a directory with .jpg, .gif and .png image files. You only want the .png files to show in the directory listings. Add this line to your .htaccess.

IndexIgnore *.gif *.jpg

The web server now ignores the .gif and .jpg files.


4. Modify Index File[Bearbeiten]

Maybe you don't want a list of the files, you want a specific file to be shown instead. You could upload an index.html file in this directory. There is another way.

DirectoryIndex myfile.html

Instead of listing the files, web page myfile.html will now be shown for this directory and its subdirectories.