在Drupal系統內建立.well-known資料夾?
(本文解法適用於Drupal 7、Drupal 8)
如果你需要申請SSL For Free的SSL憑證,
其中一個驗證方式就是在網站根目錄建立『.well-known』、『acme-challenge』2層資料夾!
但為什麼資料夾已建立、權限也給了,使用瀏覽器瀏覽驗證檔時,仍然出現『Permission Denied』?
原因就是Drupal預設的.htaccess已經阻擋了『.』開頭的『隱藏資料夾』!
假設你已經建立了『.well-known』、『acme-challenge』2層資料夾!
Step 1
編輯.htaccess
1 |
[andy@www ~]$ sudo vim /網站根目錄/.htaccess |
尋找設定值『RewriteRule “(^|/)\.” – [F]』,把它註解起來
在下一行新增設定值『RewriteRule “/\.|^\.(?!well-known/)” – [F]』
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# Block access to "hidden" directories whose names begin with a period. This # includes directories used by version control systems such as Subversion or # Git to store control files. Files whose names begin with a period, as well # as the control files used by CVS, are protected by the FilesMatch directive # above. # # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is # not possible to block access to entire directories from .htaccess, because # <DirectoryMatch> is not allowed here. # # If you do not have mod_rewrite installed, you should remove these # directories from your webroot or otherwise protect them from being # downloaded. #RewriteRule "(^|/)\." - [F] RewriteRule "/\.|^\.(?!well-known/)" - [F] |
存檔離開
開啟瀏覽器測試!