2017-06-22 40 views
0

我正在研究一個.htaccess文件,並且遇到了一些好奇的行爲,我很想知道一些關於REQUEST_FILENAME的問題。我有兩個規則,我測試了它們是像這樣:mod_rewrite REQUEST_FILENAME更改規則後沒有L標誌

RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule ^.*$ /index.php [QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^/index.php$ /other_page.php [L] 

當我試圖去地址site.com/this_file_exists.php我似乎得到到other_page.php,這意味着 REQUEST_FILENAME是在第一的RewriteCond文件但不是 時間mod_rewrite處理的第二個RewriteCond。

改變第二重寫規則的標誌,以[L,E=RF:%{REQUEST_FILENAME}]後,與荷蘭國際集團echoother_page.php$_SERVER['REDIRECT_RF'],我發現該請求的文件名只是/index.php,而不是原來的文件名,這是/full/path/to/this_file_exists.php

mod_rewrite是否在匹配RewriteRule後以這種方式一致覆蓋REQUEST_FILENAME?如果是這樣,是否有文件記錄的方式呢?

回答

0

mod_rewrite.c

/* Now adjust API's knowledge about r->filename and r->args */ 
r->filename = newuri; 

這些線路似乎表明,新的REQUEST_FILENAME確實是 重寫的URI。

+0

嘗試檢查[文檔在這裏](http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond),有一節討論'REQUEST_FILENAME'部分。 – SuperDuperApps