0

大家好,我需要一个帮助,我在我的应用程序 Kohana 中使用,并为 imgs、css 和 js 创建了一个名为 media 的根文件夹,所以我想在没有 url 的情况下保护对它的访问以使网站正常运行,是这样做的吗?

例子:

  • 应用程序文件夹
  • 系统文件夹
  • 模块文件夹
  • 媒体新文件夹(我需要保护这个文件夹)
  • 索引.php

我在根目录中的文件 .htaccess 是:

# 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]
4

1 回答 1

0

You are talking about hotlinking.

Return 403 Forbidden with .htaccess (assuming example.com is your domain name):

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

Here is a special generator: http://www.htaccesstools.com/hotlink-protection/

于 2012-11-12T16:00:17.150 回答