Startsida Senaste nytt nyfiken blog


Since this page might prove useful to people outside Sweden too, I'll do it in English.


Will write more about .htaccess in general here, sometime later...



I want an automatic index listing, no index.html, and I want e.g. Perl files to be downloadable, not executable. I have earlier used this domain for testing, and for some reason it was indexed by search engines that still come here looking for non existing documents. I want to tell them that anything not here now is gone for good.

    IndexIgnore robots.txt cgi-bin footer.html
    RemoveHandler .pl .cgi
    IndexOptions DescriptionWidth=*
    #IndexOptions FancyIndexing
    AddDescription "Source files" src
    AddDescription "Perl script" .pl
    ReadmeName footer.html
    RewriteEngine On
    RewriteCond /%{REQUEST_FILENAME} !-f
    RewriteCond /%{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ - [G,L]

IndexIgnore line will make sure that robots.txt and cgi-bin directory are not visible in the listing. Only things available to the public are listed.

RemoveHandler says that Perl files are no longer handled by the CGI handler, i.e. they will be displayed as text files instead of executed.

IndexOptions DescriptionWidth tells how long the file/dir descriptions can be, the star translates as as long as needed for the longest description.

IndexOptions FancyIndexing is not needed on my system, it is turned on by default.

AddDescription will display Perl script next to any Perl scripts, Source files next to scr/.

ReadmeName will display the footer.html file at the end of the page.

RewriteEngine, RewriteCond and RewriteRule as used here will check if the requested file or directory exists, if not return 410 Gone.

References -- autoindex -- mod_rewrite examples -- mod_rewrite raw