Forum

Hide certain file in directory listing

kai Behning
8 December 2010, 07:44

Hiawatha version: 7.3
Operating System: CentOS 5.5

Hi folks,

After using hiawatha some time now, I'm getting more and more impressed about it

But I'm currently having the following problem, not quite sure, if it's the correct way to solve it:
I have a web site (configured as a virtual host, using SSl with a user login) where I show a directory content for people to download files. It all works, and to customise the directory layout is also fine. In addition to the downloadable files, I have placed some system related files, e.g. An error file for 403 error and some php scripts, in a subdirectory called system, for this virtual host.

If the user clicks on the system directory, he gets an error message, because i restricted access to this directory.
However, it would be much better, if the system subdirectory would not be displayed in the directory listing at all. Is that possible ?? Can i prevent certain files from being displayed ina directory listing ??

Any idea is very appreciated. I'm still flexible with the website layout, so the directory can be named to whatever is best to solve this issue.

Many tx inadvance for your help, ...

Cheers

Kai
Hugo Leisink
8 December 2010, 15:09
Directory indexes in Hiawatha are created via an XSLT sheet. The default sheet is located in the Hiawatha configuration directory (/etc/hiawatha/index.xslt). Instead of using "ShowIndex = yes" (which will make Hiawatha use the default XSLT sheet), you can also use "ShowIndex = /path/to/alternate/index.xslt". In that new index.xslt file, you can use XSLT commands to hide certain directories.

If you don't know enough about XSLT, tell me which directory you want to hide and I'll create one for you.
Kai Behning
8 December 2010, 18:24
Hello Hugo,

great

I already played around with the xslt file and had no problems to add certain html code to customise the layout of the directory index.
Unfortunately, I have no clue about XSLT, so if you can give me a template which hides the directory system from the display in the directory list, that'll be great.

Many, many, many tx for your help.

Cheers

Kai
Hugo Leisink
8 December 2010, 20:35
Look in index.xslt and search for this code (around line 100):
<xsl:for-each select="files/file">
...
</xsl:for-each>


Change it into this:
<xsl:for-each select="files/file">
<xsl:if test=".!='system/'">
...
</xsl:if>
</xsl:for-each>
Kai Behning
9 December 2010, 12:07
THIS WORKS PERFECT !!!!!

Have a nice day in the snow

Cheers

Kai
Kai Behning
10 December 2010, 08:55
... sorry to bother you again, but can I also get the currently logged in username via xsl (I use a password file to log in to the site) ??
If so, can you please let me know the selector name ??

Many tx.

Cheers

Kai
Kai Behning
10 December 2010, 09:38
not too difficult to find, so it's solved now ...

... better think before writing ..., sorry ...

Cheers

Kai

btw: the selector's name is remote_user
Hugo Leisink
10 December 2010, 09:40
The selector should be $REMOTE_USER. Note that when there is no remote user, the parameter still exists, but contains an empty string.
This topic has been closed.