WordPress中以及很多php程序都會使用htaccess來控制靜態(tài)化,以及一些特殊參數(shù)。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?id=$1
</IfModule>
很多人問過RewriteCond %{REQUEST_FILENAME} 是什么意思
RewriteCond %{REQUEST_FILENAME} !-f
代表的意思就是
如果文件存在,就直接訪問文件,不進行下面的RewriteRule.
RewriteCond %{REQUEST_FILENAME} !-d#如果目錄存在就直接訪問目錄不進行RewriteRule
同理:
RewriteCond %{REQUEST_URI} !^.*(.css|.js|.gif|.png|.jpg|.jpeg)$ #如果是這些后綴的文件,就直接訪問文件,不進行Rewrite
其中,
%{REQUEST_FILENAME}表示請求的文件名
!-f不是一個文件
!-d不是一個目錄
[L] 這是最后一個匹配項,不再往下匹配
[R]相當與redirect [NC]不區(qū)分大小寫。
贊
0
賞