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,662
  • 2
  • 36
  • 52
JonE
  • 2,474
  • 4
  • 32
  • 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. – JonE 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. – JonE 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. – JonE 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

8
<Directory /uploads>
   Options +Indexes
</Directory>
javier_domenech
  • 5,480
  • 5
  • 35
  • 56
Explosion Pills
  • 183,406
  • 48
  • 308
  • 385
  • How to remove .htaccess password protection from a subdirectory https://stackoverflow.com/a/1431399/3548026 – pixelDino Mar 10 '19 at 10:54
3

Give permission in .htaccess as follows:

<Directory "Your directory path/uploads/">
Allow from all
</Directory>
Micha Wiedenmann
  • 18,825
  • 20
  • 87
  • 132
Dhruvisha
  • 2,450
  • 1
  • 20
  • 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. – JonE 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,334
  • 2
  • 16
  • 37
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