如何使用htaccess Kohana 3.2 App保护文件夹

时间:2012-11-12 13:22:51

标签: .htaccess kohana

大家好我需要一个帮助,我在我的应用程序Kohana中使用,并创建了一个名为media的根文件夹到imgs,css和js所以我想保护访问它而不需要网站的url才能正常运行,这样做?

示例:

  • app文件夹
  • 系统文件夹
  • modules folder
  • 媒体新文件夹(我需要保护此文件夹)
  • 的index.php

我的文件.htaccess在root中是:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>


# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]



# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d




# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

1 个答案:

答案 0 :(得分:0)

您在谈论hotlinking

返回403禁止使用.htaccess(假设example.com是您的域名):

RewriteEngine On 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC] 
RewriteCond %{HTTP_REFERER} !^$ 
RewriteRule \.(jpe?g|gif|bmp|png|js|css)$ - [F] 

这是一个特殊的生成器:http://www.htaccesstools.com/hotlink-protection/