1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How To Block Direct Access To Specific Files

Discussion in 'General Programming Chat' started by The Scarlet Pimp, Mar 18, 2010.

  1. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Apr 2, 2008
    Likes Received:
    Chair moistener.
    if you have files that you don't want anyone to view, this is an easy way to
    stop snoopers.

    just put this in your htaccess file and add the names of the files you don't want snoopers to see. in this example if someone tries to view any file that is named 'secretfile' or 'secretporn' (regardless of the extension) they will be told the page no longer exists on the server.

    note: if you put this in your root folder it will block everything below it. otherwise you can just put it in the specific folder that you want to protect, but leave out the "/" and just enter the name of the files.

    RedirectMatch gone /secretfile.*

    RedirectMatch gone /secretporn.*

    this is the message snoopers will see:


    The requested resource
    is no longer available on this server and there is no forwarding address. Please remove all references to this resource.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.