我在我的網站根部有一個htaccess,像這樣:
RewriteEngine On
RewriteRule .php$ - [L,NC]
RewriteRule ^(?:favicon.ico|(?:index|custom500|custom404).html)$ - [L,NC]
RewriteCond %{REQUEST_FILENAME}! !-f
RewriteRule . index.php?source=$0 [L,QSA]
我想讓它忽略那些包含特定檔案夾folder1的urls。尿液將是這樣的:
https://mycooldomain.com/folder1/api/rest/... //這里有一些其他的東西
我研究了這個問題,但我似乎無法將其應用于我的情況。
uj5u.com熱心網友回復:
有這樣的情況:
RewriteEngine On
# 忽略以/folder1/開頭的請求URLs
RewriteCond %{THE_REQUEST} s/ folder1/ [NC]
RewriteRule ^ - [L]
RewriteRule .php$ - [L,NC)
RewriteRule ^(?:favicon.ico|(?:index|custom500|custom404).html)$ - [L,NC]
RewriteCond %{REQUEST_FILENAME}! !-f
RewriteRule . index.php?source=$0 [L,QSA]
uj5u.com熱心網友回復:
與@anubhava的答案相比,唯一需要在你的.htaccess檔案中被忽略的規則是最后一條。因此,你可以在最后一條規則中添加一個條件,排除以/folder1/開頭的URL路徑。
例如:
RewriteCond %{REQUEST_URI} !^/folder1/!
RewriteCond %{REQUEST_FILENAME}! !-f
RewriteRule . index.php?source=$0 [L,QSA]
!前綴在!^/folder1/上否定了重碼,所以當它不匹配時就成功了,即當URL路徑不以/folder1/開始時。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/310713.html
標籤:
