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?

5
  • is this .htaccess in upload folder ?
    – safarov
    Apr 10, 2012 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, 2012 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, 2012 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, 2012 at 10:34
  • 1
    remove <Directory> block from htaccess keep it in upload folder and try again
    – safarov
    Apr 10, 2012 at 10:38

4 Answers 4

9
<Directory /uploads>
   Options +Indexes
</Directory>
1
5

Give permission in .htaccess as follows:

<Directory "Your directory path/uploads/">
Allow from all
</Directory>
3
  • 1
    put your .htaccess file in your project folder not in upload folder. Is your OS linux?
    – Dhruvisha
    Apr 10, 2012 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, 2012 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". Jul 9, 2013 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

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

1
  • Please elaborate: What does that option do? Thanks! May 9, 2017 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.