我正在使用Kohana框架。它具有.htaccess
文件的以下配置:
# 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 [PT]
我特别感兴趣的是第二部分Allow any files or directories that exist to be displayed directly
。有人可以详细说明它是如何配置的吗?
答案 0 :(得分:0)
这是由于2个条件行使用RewriteCond
指令,其作用类似于if condition
RewriteCond %{REQUEST_FILENAME} !-f
表示请求不是有效文件
RewriteCond %{REQUEST_FILENAME} !-d
表示请求不是有效目录
两者结合下面的RewriteRule
表示如果请求不是有效的文件或目录,则将每个请求转发到index.php