2
我在我的htdocs .htaccess文件/ MVC /文件夾,看起來像這樣htaccess中的mod_rewrite:防止循環的最好方法?
RewriteEngine On
# if its already been rewritten to the specific folder
RewriteCond %{REQUEST_URI} ^/MVC/public/img/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/MVC/public/index.php$
# skip next two rules
RewriteRule .? - [S=2]
# rewrite image requests
RewriteRule (.*\.(jpg|png|gif))$ public/img/$1 [L]
# rewrite all other requests to the front controller index.php
RewriteRule (.*) public/index.php?url=$1 [QSA,L]
我想實現的是將文件夾MVC /公/ IMG所有其他請求將所有圖像請求MVC/public文件夾中的前端控制器index.php。這是設置這些規則並防止mod_rewrite循環的最佳方式嗎?
感謝您的幫助和解釋。奇蹟般有效。我同意你所說的'S'國旗。關於ENV:REDIRECT_STATUS,是否有這些環境變量的清單和很好的解釋? – Dalai