I'm using xampp with apache on my windows machine. My directory structure is:

-------------------------------------/A.zip, B.zip ...
------------------------/.htpasswd, htgroup

I want to list the ProtectedFolderA and B if I open localhost/Sync/. They contain some files which are restricted by HTTP Auth. If i open them they should list the files in the way specified in the htaccess. The etc directory contains some images and css. I also change some preferences like header and icons. So this is my .htaccess in ProtectedFolderA:

RewriteEngine On
AuthType Basic
AuthName "Restricted Directory"
# Only allow request after authentication
AuthUserFile c:/xampp/htdocs/Sync/etc/.htpasswd
AuthGroupFile c:/xampp/htdocs/Sync/etc/.htgroup
require valid-user

Options +Indexes
IndexOptions HTMLTable
IndexOptions FancyIndexing
IndexOptions IconsAreLinks
IndexOrderDefault Descending Name
IndexStyleSheet C:/xampp/htdocs/Sync/etc/file_style.css
HeaderName C:/xampp/htdocs/Sync/etc/file_head.html
IndexOptions FoldersFirst
IndexOptions NameWidth=90
IndexIgnore *.php *.htaccess *.html *.xhtml *.xmi *.xml *.png *.jpg *.css *.txt
AddIconByType C:/xampp/htdocs/Sync/etc/file_stock_index_down.png application/zip 
<Files *.zip>
deny from all
<filesMatch A.zip>
AuthName "Download A.zip"
AuthType Basic
Require group A
Order allow,deny
Allow from all

<filesMatch B.zip>
AuthName "Download B.zip"
AuthType Basic
Require group B
Order allow,deny
Allow from all

<filesMatch C.zip>
AuthName "Download C.zip"
AuthType Basic
Require group C
Order allow,deny
Allow from all

But there are no changes on the icons. Are the path to the css and pictures are wrong? I can't open the css file in the code view.

  <title>Index of /Sync/V6</title>
  <link rel="stylesheet" href="C:/xampp/htdocs/Sync/etc/file_style.css" type="text/css">

Firefox says that it doesnt know the protocol "C". But I don't know a better path?! I don't know what I'm doing wrong. RewriteEngine is enabled. Some ideas?

  • Have you not tried using relative paths? So, instead of C:\xampp\..., you would use ..\etc\... – Mike Anthony Mar 26 '13 at 19:55
  • Yes I tried AuthUserFile ../etc/.htpasswd but apache error log says Could not open password file: C:/xampp/etc/.htpasswd which is totally weird because the parent folder from the .htacess is not xampp. So I used AuthUserFile ../htdocs/Sync/etc/.htpasswd and this works. For the Icons i can use the previous relative path. But the folder ProtectedFolderA is not shown in the Sync folder anymore. So an user can't know that its there. – No3x Mar 27 '13 at 8:45
  • And the etc folder is shown anyway. Right the way I don't want to. It just contains resources that shouldn't be seen from a user. – No3x Mar 27 '13 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy