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

4

2 回答 2

1

使用“FilesMatch”标签解决问题。

在 RewriteCond 和 RewriteRule 之后添加:

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

注意:请在管道 ' | 之间添加错误日志文件的扩展名。'符号。另外请删除您不想要的扩展名。

更多信息: 如何使用 apache .htaccess 隐藏某些文件类型?

于 2013-01-24T16:52:29.970 回答
0

我不是 .htaccess 大师,但您应该能够将其更改为:

## 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\/*\.jpgLib目录下任何 jpg 文件的正则表达式

于 2013-01-24T13:20:37.550 回答