Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:56:15+00:00 2026-05-16T07:56:15+00:00

I am using a GoDaddy web hosting plan on a Windows platform. This was

  • 0

I am using a GoDaddy web hosting plan on a Windows platform. This was not my choice — it has to do with a different part of the actual site using ASP.NET (also not my choice).

I have a SQL database with a bunch of entries with some non-sensitive customer information. The primary key on this is an AutoIncrement integer, and I have a series of PDF files that match up with each of those integers (e.g. 555.pdf, 7891.pdf, etc).

My goal is to restrict direct access to these files, I want users to have to go through a search and login process (PHP) first. Originally I planned to put the files above the PUBLIC_HTML folder, but GoDaddy refuses to give me root access without a dedicated server ($20 a month from them).

The next thing I looked into was HTACCESS. I was going to restrict access to the files to only PHP scripts by only allowing access to the Server’s IP Address (or localhost/127.0.0.1). Unfortunately this doesn’t work because GoDaddy does not run Apache on its Windows servers.

I could put the files into BLOBs in the database, but that gets really messy when I need to work with them quickly (plus I have had some trouble with that approach).

Any suggestions to restrict access to the files only to a PHP script (readfile())?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:56:16+00:00Added an answer on May 16, 2026 at 7:56 am

    Since you can’t put the files anywhere but in your public_html directory, you’ll have to go for the feared/hated “security by obscurity” method

    1. Create a randomly named sub-directory to store the files in: public_html/RANDOMGARBAGE

    2. Make sure the directory is not browseable. Disable directory browsing (if you can), and put a default document (index.html?) in there as well, so even if browsing is on, you won’t get the directory listing.

    3. Don’t store your files with guessable names. Instead of storing them with the database ID, store them with a salted+hashed name instead: $crypted_filename = sha1($real_filename . 'some hard-to-guess salt text'); (of course, make this more complex if you need to). Store the original filename in your database. So you end up with something like:

      public_html/RANDOMGARBAGE/5bf1fd927dfb8679496a2e6cf00cbe50c1c87145
      public_html/RANDOMGARBAGE/7ec1f0eb9119d48eb6a3176ca47380c6496304c8

    4. Serve up the files via a PHP script – never link to the hashed filename directly

      Download

    which then does:

    <?php
    
        $fileID = (int)$_GET['fileID'];
    
        $crypted_file = sha1($fileID . 'some hard-to-guess salt text');
    
        $full_path = 'public_html/RANDOMGARBAGE/' . $crypted_file;
        if (is_readable($full_path)) {
             if(user_is_allowed_to_see_this_file()) {
                 /// send file to user with readfile()
                 header("Content-disposition: attachment; filename=$ORIGINAL_FILENAME");
                 readfile($full_path);
             } else {
                 die("Permission denied");
             }
        } else {
            /// handle problems here
            die("Uh-oh. Can't find/read file");
        }
    

    This way the user will never see what your “s00per seekrit” filename is, they’ll just see their browser hit ...php?fileID=37 and start a download of secret file.pdf

    On top of this, you can occasionally rename the special sub-directory to something else on a regular basis, as well as change the salt text (which then requires you update all the hashed filenames with the new sha1 values).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Upgraded server Framework to 4.0. Using Godaddy hosting. The website is now showing this
I'm not sure if this is possible using regular hosting plans like those from
I have godaddy hosting and I am using it to host multiple domains. With
I am using my Mac Terminal to SSH into my GoDaddy hosting account. I
I purchased a Windows shared hosting account on godaddy that came with 2 MSSQL
I am using MySQL 5.0 for a site that is hosted by GoDaddy (linux).
I am using Godaddy Deluxe hosting which allows me to host several websites in
I've been struggling with getting this syntax right to send mail using Godaddy. Any
We are getting a SecurityException when using Entity framework on godaddy. The entity has
I am using godaddy.com for my website hosting Can i use HTML::Template in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.