2013-06-21 47 views
1

我有一個名爲test的文件夾,我可以通過http://domain.com/test訪問它。我試圖發送http://domain.com/test/XXX(XXX =每件東西)的每個請求到php file.htaccess子目錄中的規則

test/.htaccess用這個:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /test 
RewriteRule ^(.*)$ /control.php?path=$1 [L] 
</IfModule> 

control.phptest文件夾了。但它不起作用,我不知道在哪個規則我犯了一個錯誤!現在每個http://domain.com/test/XXX請求顯示一個404 not found page

回答

1

試試這個代碼:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /test/ 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^(.*)$ control.php?path=$1 [L] 
</IfModule> 
+0

什麼是'RewriteCond's呢? – revo

+0

爲了避免對物理目錄,文件或鏈接應用重寫規則 – anubhava

+0

是的,但在我的情況下,它應該適用於所有這些! – revo