Codeigniter .htaccess: Give public access to all files but not the folder

12,176

Blocking directory access can be done by simply putting a index.html file in the folder you want to block directory access to.

This is the way the standard CodeIgniter install does it. The below index.html file can be found in the application\controllers folder.

<html>
<head>
    <title>403 Forbidden</title>
</head>
<body>
    <p>Directory access is forbidden.</p>
</body>
</html>
Share:
12,176
Malde Chavda
Author by

Malde Chavda

Updated on June 05, 2022

Comments

  • Malde Chavda
    Malde Chavda almost 2 years

    my file format like

      application
           - controllers
           - views etc...
      assetes
           - Images
           - Css etc...
    

    and my .htaccess file are below:

    #Deny from all
    RewriteEngine on
    RewriteCond $1 !^(index\.php|assets|robots\.txt)
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    My problem is that assets folder access to every one any user veiw all images and all css file but needed is only user access assets folder file not the access entire folder

    please help me thanks!

  • saurabh kamble
    saurabh kamble over 10 years
    Order allow,deny<br/> Allow from all <br/> RewriteEngine On <br/> RewriteCond %{REQUEST_FILENAME} !-f <br/> please update your .htaccess with the following code RewriteCond %{REQUEST_FILENAME} !-d <br/> RewriteRule ^(.*)$ index.php?/$1 [L] <br/>