Make user download a file placed outside public_html

Posted on 2005-05-08
Last Modified: 2010-03-04

Is there a way to allow a user to download a file placed outside of the public_html folder?
ex. /home/username/
Question by:kgp43
    LVL 38

    Expert Comment

    You can use  symbolic links, eg, put all the files in:

    then do:
    ln -s /home/username/download /home/username/public_html/download

    and make sure that apache user has "rx" permission to /home/username/download

    Author Comment

    isnt ln -s /.... a ssh command?
    how can I do that with php?
    LVL 38

    Expert Comment

    ln -s source tagart

    is a shell command, you need to do it in the shell prompt.

    Don't use  php for the job, php script run as user nobody, you need
    to do system call to run it as supper user, it is a security risk!

    Author Comment

    need it for my visitors.

    I had problems with my hotlink protection and that question found a solution on this problem.

    What do you do with this question then?
    LVL 38

    Accepted Solution

    Not sure which question are you talking about. for http:Q_21416514.html
    It is a lot easier to put the files you want to control acces in one dir, and make
    the dir only allow certain machines (IP range) can access to Or just simply use password
    login to protect the files in that dir.


    for more details also read the apache doc about .htaccess file

    Have a nice weekend, cheers!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now