Zi 字媒體
2017-07-25T20:27:27+00:00
今天把 Laravel 專案放到新建的 server 跑,出現了這個錯誤:
Refused to apply style from 'http://localhost:8080/assets/styles/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
找了很久都沒有找到原因,同時伴隨著部分頁面會出現 404。
Stackoverflow 這篇講了很多,但實際上我遇到的倒沒有這麼複雜,而且也不是因為因為 lib 引起的問題,最後在這篇找到解答,原來我只是忘記設定 Apache 的 Allow Override。
DocumentRoot /var/www/sitefolder/public
ServerName site.domain.com
AllowOverride All # 加上這行就可以了
Allow from all
Options +Indexes
最後執行 sudo systemctl reload apache2 就正常了。
References
html - Stylesheet not loaded because of MIME-type - Stack Overflow
php - Laravel redirects to a route but then apache gives 404 error - Stack Overflow
寫了
5860316篇文章,獲得
23313次喜歡