in reply to Re: Links to web page?
in thread Links to web page?

I dont understand that link at all..sorry... Kari

Replies are listed 'Best First'.
Re^3: Links to web page?
by almut (Canon) on Dec 03, 2008 at 16:55 UTC

    Are you using Apache?  If so, mod_autoindex can give you automatically generated file listings (HTML pages) of directories the server is configured to access — in case no other explicit index (index.html) is found for the respective directory. Files will typically appear as clickable links, but you can flexibly configure the appearance in many ways (file sorting, with icons, descriptions, etc.).

    To get you started, here's a sample configuration snippet (incomplete) for your httpd.conf:

    LoadModule autoindex_module modules/mod_autoindex.so LoadModule alias_module modules/mod_alias.so Alias /chat /path/to/directory/chat # ...so you can access the chat directory via http://servername/chat <Directory /path/to/directory/chat> Options +Indexes IndexOptions FancyIndexing # ... </Directory>
      Thank you but I use webhotel so I have no acces to server files.... Can it be done with CGI-script? kari
        Can it be done with CGI-script?

        Sure. The first step would be to generate HTML code for links, i.e. instead of print "$f<br />";, you'd write

        print "<a href=\"/chat/$f\"> $f </a><br />";

        The exact format of the href="..." depends on how your server is configured to access the file, whether you want it served as a static file, or delivered as a dynamic resource (via another CGI script) with a specific MIME type, or with plain text being rendered into HTML, and such...

        BTW, directly generating HTML is just the most primitive form there is...  Normally, you'd use some module (like CGI.pm, or one of the many templating modules/frameworks), which would make your life easier — among other things, by taking care of stuff like escaping special characters in file names properly, etc.