Loading...

將Google字型fonts.googleapis.com新增到CSP header 中

Temperature: 0 °C

Mark ChangMark Chang
author_tools

Content Security Policy (CSP) 內容安全政策
主要用來限制網頁中對外部的請求來源(例如:css,js(ajax,ws),webfont,img,video,iframe等等)
但這樣直接限制下去往往會影響到網站的正常運作。
以下是以.htaccess來開放Google字型fonts.googleapis.com

<IfModule mod_headers.c>
Header set Content-Security-Policy " \
default-src 'self'; \
img-src 'self' data:; \
font-src 'self' https://fonts.gstatic.com/; \
style-src 'self' https://fonts.googleapis.com/ 'unsafe-inline';\
"</IfModule>

以白名單的形式允許信任的外部來源

以上紀錄~

#故事  #CSP  #Content Security Policy  #內容安全政策  #Google字型  #白名單  
https://innstory.com/story-將Google字型fontsgoogleapiscom新增到CSP_header_中-2799
apache PHP

Prev
 如何將_a_href_禁用

Next
分享_【東京奧運開幕典禮】超級變變變!超創意呈現1964年的50個靜態項目圖標 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

.htaccess與RewriteEngine一起使用時500內部服務器錯誤

.htaccess與Rewr...

在某些情況下,可能未加載apache中的modrewrite模塊。 這時只需要執行以下指令就可以獲得...

PHP–implode() 將陣列轉成字串

PHP–implode() ...

pexelsphoto 使用implode將陣列轉換成字串; $ar=array(&#;a&#;,&...

JavaScript 取得今天日期

JavaScript 取得今...

JavaScript 使用 Date() 來取得時間的資訊。 再使用指令如 getDate()、ge...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format