Primm
Primm

Reputation: 1387

PHP - Deny folder access without direct link to file?

I am creating a file hosting website. I would not like people to access the directory

public_html/quick/files

unless they have a direct download link from uploading a file. How would I go about this?

For others: To rephrase, deny permission to index all the files.

Upvotes: 1

Views: 663

Answers (2)

Snow Blind
Snow Blind

Reputation: 1164

Create a file named .htaccess in public_html folder with this content:

Options -Indexes

Upvotes: 3

FabianoLothor
FabianoLothor

Reputation: 2977

Creates a blank index.html file in the directories.

If thought necessary, create a redirect to an error page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;url=<URL_ERROR_PAGE>"></HEAD>
<BODY>
    Optional page text here.
</BODY>
</HTML>

Upvotes: 1

Related Questions