Results 1 to 6 of 6

Thread: [RESOLVED] how to prevent a request from outside my website via .htaccess

  1. #1
    Addicted Member
    Join Date
    Feb 10
    Location
    Damascus - Syria
    Posts
    133

    Resolved [RESOLVED] how to prevent a request from outside my website via .htaccess

    Hi

    I have a folder "files" which is located in the public_html folder, it has documents and files. These files are only available for registered users, I am managing download via "download.php" file which doesn't view the document url (using header function).

    but if the user did some tricks and knew the folder path with file name, he could download it even without permissions, so please help to prevent this type of request, I know this is htaccess job but don't know how to do it

    thanks

  2. #2
    Moderator
    Join Date
    Jan 05
    Location
    Sydney
    Posts
    13,615

    Re: how to prevent a request from outside my website via .htaccess

    Move 'files' up one level.

  3. #3
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 08
    Location
    Trivandrum, Kerala, India
    Posts
    7,559

    Re: how to prevent a request from outside my website via .htaccess

    You could also create an htaccess file in that directory, with the statement:
    Code:
    deny from all
    That would deny direct access to the files in that directory.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD Athlon X2 5200+, ASUS Motherboard, 2 GB RAM, 400 GB HDD, Nvidia 8600 GT 512MB, 19.5" TFT(Wide), Creative 5.1 Home Theater

    Social Group: VBForums - Developers from India

    Skills: PHP, MySQL, jQuery, VB.Net, VB6, Photoshop...

  4. #4
    Addicted Member
    Join Date
    Feb 10
    Location
    Damascus - Syria
    Posts
    133

    Re: how to prevent a request from outside my website via .htaccess

    nice trick from you mr. penagate

    I am compelled to use htaccess because I need to include some videos from 'files' too (this was not mentioned above, sorry) thanks very much akhileshbc

  5. #5
    Moderator
    Join Date
    Jan 05
    Location
    Sydney
    Posts
    13,615

    Re: how to prevent a request from outside my website via .htaccess

    Quote Originally Posted by fjober View Post
    nice trick from you mr. penagate
    It's the standard way of controlling access.

    Even if the files are outside the web root directory, you can still serve them using a script, which also takes care of authentication.

  6. #6
    Addicted Member
    Join Date
    Feb 10
    Location
    Damascus - Syria
    Posts
    133

    Re: how to prevent a request from outside my website via .htaccess

    hmmmm , double like thanks very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •