close
今天想讓網站在瀏覽時能加上權限控管機制,所以設了 .htaccess,但一設就出現錯誤訊息 "Internal Server Error"。
追查順序如下:
- 看 php 的 error log (php_error.log),裡面沒有提到這個錯誤。
- 查 Apache 的 access.log,沒看到什麼,只看到 HTTP 1.1 status 500 533 的錯誤,但查了一下好像也沒什麼東西。
- 看 Apache 的 error.log,找到問題了。
[Wed Oct 31 11:42:05 2012] [error] [client 127.0.0.1] (OS 2)系統找不到指定的檔案。 : Could not open password file: C:/Apache2/.htpasswd
原來密碼檔 (.htpasswd) 的路徑要寫成絕對路徑,我的網站放在 D:\MySite,如果我寫相對路徑,系統會跑到 Apache 去找 .htpasswd。
所以把 .htaccess 裡的這一行:
AuthUserFile .htpasswd
改成這樣:
AuthUserFile D:\MySite\.htpasswd
這樣就好了。
--
2016/10/06
今天出現的錯誤訊息是:
Forbidden
You don't have permission to access / on this server.
Server unable to read htaccess file, denying access to be safe
經確認後是 .htaccess 的權限無故被拔掉了,因為我們是 Winodws Server,重新對 .htaccess 檔案右鍵→內容→安全性頁籤,把執行 Apache 的 User 加進來,就可以了。
文章標籤
全站熱搜