18

I have an images folder at the following URL.

www.mysite.com/uploads/

On a different page:

www.mysite.com/search.php/

I am trying to access the images wherein, with a correct tag link, however I get the :

Forbidden

You don't have permission to access /uploads/ on this server. 

So I went and started dabbling with a .htaccess file, and I have no idea what I am doing ,I tried looking at some documentation but with no luck, I even took an example off another question..Here is how my .htaccess file looks atm:

<FilesMatch "\.(gif|jpe?g|png)$">
Order allow,deny
Allow from all
</FilesMatch>

<Directory /uploads>
# All access controls and authentication are disabled
# in this directory
Satisfy Any
Allow from all
</Directory>

Any ideas on how I can have it allow access to that folder?

safarov
  • 7,793
  • 2
  • 36
  • 52
JEV
  • 2,494
  • 4
  • 33
  • 47
  • is this `.htaccess` in upload folder ? – safarov Apr 10 '12 at 10:31
  • I had it in there, and it didn't work, and I had it in the root aswell. Still no luck. – JEV Apr 10 '12 at 10:32
  • If I have it in root I get : Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. – JEV Apr 10 '12 at 10:33
  • I want to allow people to view the images within, so I can link to them and have them show up on other pages. – JEV Apr 10 '12 at 10:34
  • 1
    remove `` block from `htaccess` keep it in upload folder and try again – safarov Apr 10 '12 at 10:38

4 Answers4

9
<Directory /uploads>
   Options +Indexes
</Directory>
javier_domenech
  • 5,995
  • 6
  • 37
  • 59
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
  • How to remove .htaccess password protection from a subdirectory https://stackoverflow.com/a/1431399/3548026 – pixelDino Mar 10 '19 at 10:54
5

Give permission in .htaccess as follows:

<Directory "Your directory path/uploads/">
Allow from all
</Directory>
Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
Dhruvisha
  • 2,538
  • 1
  • 21
  • 31
  • 1
    put your .htaccess file in your project folder not in upload folder. Is your OS linux? – Dhruvisha Apr 10 '12 at 10:45
  • Windows; and Project folder? I am putting it in my root with all the other php files and such. The directory above uploads. – JEV Apr 10 '12 at 10:48
  • 2
    The quotes you used won't work since they are those (open and closed) quotes that word-processors tend to use. They will not function like the normal "double quotes". – Daniël Voogsgerd Jul 09 '13 at 11:28
3

Create a .htaccess file in the images folder and add this

<IfModule mod_rewrite.c>
RewriteEngine On
# directory browsing
Options All +Indexes
</IfModule>

you can put this Options All -Indexes in the project file .htaccess ,file to deny direct access to other folders.

This does what you want

Abilogos
  • 4,777
  • 2
  • 19
  • 39
Joshkeys
  • 31
  • 3
1

Having the .htaccess file on the root folder, add this line. Make sure to delete all other useless rules you tried before:

Options -Indexes

Or try:

Options All -Indexes

user3821381
  • 114
  • 2