2017-08-28 57 views
1

我有這個代碼在.htaccess項目:的.htaccess mod_rewrite的排除根

# If the requested filename exists, simply serve it. 
# We only want to let Apache serve files and not directories. 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 

# Rewrite all other queries to the front controller. 
RewriteRule^%{ENV:BASE}/app.php [L] 

所以現在每一個請求(除了明確的文件)發送到/app.php。

我想改變這種行爲: 如果有人請求域沒有任何進一步的文件或目錄index.php應該顯示。在所有其他情況下,應該執行給定的行爲。

如何實現這一目標?

回答

1

要排除您可以使用以下條件的根文件夾

RewriteCond %{REQUEST_URI} !^/$ 

嘗試:

RewriteCond %{REQUEST_URI} !^/$ 
RewriteRule^%{ENV:BASE}/app.php [L]