1 回答

TA貢獻1786條經驗 獲得超11個贊
RewriteConds 僅適用于緊隨其后的一個RewriteRule,因此您必須在每個 RewriteRule 之前重復它們。
在這里使用否定模式可能更有意義 - 檢查主機名是否不是 mydomainname.com,然后通過使用 [L] 標志簡單地說“好的,我們在這里完成”的規則來遵循。
RewriteEngine On
RewriteBase /
# check if the host name was not mydomainname.com
# pattern anchored at the start using ^ as well here, so that notmydomainname.com
# would not be matched as well, and the . escaped
# whole thing negated, by putting ! in front of it
RewriteCond %{HTTP_HOST} !^mydomainname\.com$ [NC]
# match absolutely anything with the .
# don’t do any actual rewriting, by using - as the substitution
# [L] flag to say, that’s it, we are done with the rewriting here
RewriteRule . - [L]
# … rest of your rules follow here
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# …
- 1 回答
- 0 關注
- 100 瀏覽
添加回答
舉報