Hallo!

I have a folder with name "uploads" in my root directory.
How do I can forbid the users to enter directly into this directory.

For example If the user writes this www.mysite.com/uploads I want restrict directly access!

Possibly with .htaccess

Can somebody help?

    If its just to stop the user viewing the directory root you could just place an index page in there that directs to another page.

    or in your htaccess...

    RewriteEngine On
    RewriteRule ^uploads/$ /error.php

    replace error.php with your page that lets the user know that it is not allowed.

      Put this in a .htaccess file in the uploads <dir>:

      AuthUserFile .htpasswd
      AuthName "Upload Directory"
      AuthType Basic
      <Limit GET POST>
      require valid-user
      </Limit>
      

      snd put this in a .htpasswd file:

      #replace <username> and <password> with actual details, also you can encrypt the password with a free online tool. Also I reccomend you find a way to restrict filnames with '.ht' in them.
      <username>:<password>
      
        <FilesMatch "^\.ht">
            Order allow,deny
            Deny from all
        </FilesMatch>
        

        to block all access to .ht files

          bradmasterx wrote:
          <FilesMatch "^\.ht">
              Order allow,deny
              Deny from all
          </FilesMatch>
          

          to block all access to .ht files

          Exactly!

            Write a Reply...