我看到了一个 .htaccess 文件,其内容如下
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
据我了解,重写条件表明,如果请求的 url 用于大小非零的文件、符号链接或目录,则什么也不做。这是通过 , 完成的
RewriteRule ^.*$ - [NC,L]
,意味着如果上述条件为真,则立即停止处理;否则调用/index.php
并使用RewriteRule ^.*$ /index.php [NC,L]
.
我的疑问是,
1.In the tutorial ( Survive the deep end ) 我正在阅读,说:
即如果 URL 引用文件(大小大于零)、目录或符号链接。这确保您的 javascript、css 和其他非 PHP 文件可以直接提供服务,即使集中在其他地方并且仅由符号链接引用。
由于所有 .php 文件都是非零大小,那么 apache 怎么知道 php 文件和非 php 文件之间的区别?
2.请求的 url 将作为参数传递给 /index.php 还是只调用 /index.php ?