0

I have a web project and i have created an external photo library for my project.The photo library is outside the web root directory e.g My Codeigniter project is in C:\wamp\www\myprject\application\ but my photo library is under C:\wamp\www\myprject\Lib\

My .htaccess file (under my application folder ) successfully displays the library using the commands below:

.htaccess file

RewriteEngine on  
RewriteCond $1 !^(index\.php|images|Lib|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php?$1 [L]

But the problem is this .htaccess file is also displaying my error_log file along with all the images in the library directory. What changes i will need to make in this .htacess file to hide it?I just want to display (.jpg,gif,.bmp,.jpeg) files.Please help.Thanks

Bilal Khalid
  • 95
  • 5
  • 22

2 Answers2

1

Do workarounds with 'FilesMatch' tag.

Add this after your RewriteCond and RewriteRule:

<FilesMatch "Lib\.(htaccess|htpasswd|ini|log|error_log|error|sh|inc|bak)$">
Order Allow,Deny
Deny from all
</FilesMatch>

Note: please add your error log file's extenstion in between the pipe ' | ' symbols. Also please remove extensions that you don't want.

More info: How to hide certain file type using apache .htaccess?

Community
  • 1
  • 1
Jirilmon
  • 1,924
  • 1
  • 12
  • 13
0

I'm not an .htaccess guru, but you should be able to change it to:

## NOT TESTED ##
RewriteEngine on  
RewriteCond $1 !^(index\.php|images|Lib\/*\.jpg|Lib\/*\.gif|Lib\/*\.bmp|Lib\/*\.jpeg|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php?$1 [L]

Lib\/*\.jpg is a regex for any jpg file under the Lib directory

swatkins
  • 13,530
  • 4
  • 46
  • 78