Make files on the server visible, yet not downloadable

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Make files on the server visible, yet not downloadable

Postby mononoke » 16. April 2014 08:54

Hello everyone,

I'm kinda new to apache, and would need help setting up 4 little things.

The main use I have of apache is to make directory listings of folders on my hard drive. (same as http://ftp.mozilla.org/pub/mozilla.org/ in a way)
So what I basically did so far was replace the "DocumentRoot" path to a folderpath of my choosing. (in httpd.conf)
The server is online, but I'd like help from apache gurus :)

I wanna know
1) How to have a combined view of (for example) both D:\Music\ & E:\Video\ when accessing the website url (I believe it's called "Alias" in FileZilla, not sure about apache)
2) how to make it so the files in the listings can not be downloaded

For reference, here's what I modified so far in httpd.conf: http://pastebin.com/LvLEXS38

Thank you very much for your help
Last edited by mononoke on 19. April 2014 20:32, edited 2 times in total.
mononoke
 
Posts: 4
Joined: 16. April 2014 08:34
Operating System: Windows 7 Ultimate

Re: Help setting up apache

Postby gsmith » 17. April 2014 03:06

1. It's called Alias in Apache, not sure about FileZilla.
4. Simple as putting an empty README.html file in the folder/s being listed
3. is a browser thing as far as I know

That leaves #2 which is a problem because Apache will not show anything in a directory listing that the user is being denied access to. This is more suitable for FileZilla which will list everything but you can also deny read permissions to everything at the same time. Last I tried all browsers I use allow ftp:// URLs still.
gsmith
 
Posts: 194
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win XP to 2012R2/VS 6,9,11,14

Re: Help setting up apache

Postby mononoke » 17. April 2014 08:32

Thanks for your reply, gsmith, much appreciated!

I'll cross 3) & 4) then, considered fixed :)

Indeed I made some research, and it seems to be called Alias too. But even though I made some tests with it, I can't make use of that "function", could you provide additional help please?
Also, it is possible to make the files "readable" (user will read the filenames), but can not open them nor download them.
Well, I've seen some websites listings like this, though I'm not sure they're being hosted with apache server.
mononoke
 
Posts: 4
Joined: 16. April 2014 08:34
Operating System: Windows 7 Ultimate

Re: Help setting up apache

Postby JJ_Tagy » 17. April 2014 10:59

mononoke wrote:... Also, it is possible to make the files "readable" (user will read the filenames), but can not open them nor download them ...

I would protect the files with an .htaccess file and create an index.php file using the read directory function of PHP. http://php.net/manual/en/function.readdir.php
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Help setting up apache

Postby mononoke » 17. April 2014 20:04

Hello JJ_Tagy, thank you very much for your suggestion.
Though I'm a very beginner at apache and can't handle such functions :(
Would you be kind enough to give me a template (practical example), when the root of the server is C:\xampp\apache,
and the locations of the hard drives I wanna alias are "D:\Music\" & E:\Video".

That would help me understand how it works, thank you very much.
mononoke
 
Posts: 4
Joined: 16. April 2014 08:34
Operating System: Windows 7 Ultimate

Re: Help setting up apache

Postby JJ_Tagy » 17. April 2014 22:35

example.php
Code: Select all
<?php
  $music_dir = "D:/Music";
  $videos_dir = "E:/Video";
  $has_files = false;

  echo "<center><h2><u>File Listing</u></h2></center>";
  echo "<b><u>Music</u></b><br/>";
  if ($handle = opendir($music_dir)) {
    echo "<ul>";
    while (($entry = readdir($handle)) !== false) {
      if ($entry != "." && $entry != "..") {
        echo "<li>$entry</li>";
        $has_files = true;
      }
    }
    echo "</ul>";
    if (!$has_files) {
      echo "<i>No files</i><br/>";
    }
    closedir($handle);
  }
  else {
    echo "<br/><i>Unable to open " . $music_dir . "</i><br/>";
  }
  echo "<br/><br/>";
  $has_files = false;
  echo "<b><u>Videos</u></b><br/>";
  if ($handle = opendir($videos_dir)) {
    echo "<ul>";
    while (($entry = readdir($handle)) !== false) {
      if ($entry != "." && $entry != "..") {
        echo "<li>$entry</li>";
        $has_files = true;
      }
    }
    echo "</ul>";
    if (!$has_files) {
      echo "<i>No files</i>";
    }
    closedir($handle);
  }
  else {
    echo "<br/><i>Unable to open " . $videos_dir . "</i>";
  }
?>
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Help setting up apache

Postby mononoke » 19. April 2014 20:28

Thank you JJ but what you propose is actually a listing.

What I wanted is actually to be able to browse the folders.

I ended up forwarding subdomains to specific folders on my computer hard drives (music.domain.com > D:\Music video.domain.com > E:\Video) (example)

But I haven't found a way to protect the files from being downloaded, anyone can help with that please?
(the files on the server are accessed kinda in this fashion: http://ftp.mozilla.org/pub/mozilla.org/


To sum it up: The files should be "visible" but not openable/downloadable
mononoke
 
Posts: 4
Joined: 16. April 2014 08:34
Operating System: Windows 7 Ultimate


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 47 guests