大家好我需要一个帮助,我在我的应用程序Kohana中使用,并创建了一个名为media的根文件夹到imgs,css和js所以我想保护访问它而不需要网站的url才能正常运行,这样做?
示例:
我的文件.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]
答案 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]