LMH
LMH

Reputation: 83

htaccess do not allow to access a file

enter image descriptenter code hereion here

This is my file structure. I need to get access to the images folder through a URL and get images. But I can`t access that folder. This is the URL that I need to get access. http://10.0.2.2/careuAppWeb/careu-php/images. I need to get pictures in the images folder and display it somewhere else.Is there any way that I can get access to that folder and get those images. I think the problem is my .htaccess file. This is it.

     
      Options -Indexes
      RewriteEngine on
      RewriteRule ^$ public/ [L]
      RewriteRule (.*) public/$1 [L]
    

How can I get access to Images folder.

Upvotes: 1

Views: 168

Answers (1)

MrWhite
MrWhite

Reputation: 45829

RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

You can change your mod_rewrite directives to something like the following instead:

RewriteCond $1 !^images
RewriteRule (.*) public/$1 [L]

This creates an exception for any URL to the /images subdirectory and rewrites everything else to the /public subdirectory.

The first RewriteRule you had was superfluous and is handled by the 2nd rule anyway.

This does assume you have an additional .htaccess file in the /public subdirectory that also contains mod_rewrite directives, otherwise you get a rewrite-loop.

Upvotes: 2

Related Questions