我試圖拒絕對我的網站的直接訪問和跨域訪問,所以我試圖使用通配符訪問。
只有我的網站和受信任的域才能訪問我的資產,如影像、java 腳本、css 檔案等。
我正在嘗試這樣 *.example.com 所以它將允許訪問所有 https://www.example.com , http://www.example.com , http://example.com , https://example .com , https://subdomain.example.com等
代碼 :
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^ .*\.example\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^ .*\.example\.com$ [NC]
RewriteRule .*\.(txt|ico|jpg|jpeg|gif|png|bmp|js|css)$ - [F,NC,L]
我的資產仍然沒有阻止直接訪問和跨域。
uj5u.com熱心網友回復:
你可以使用這個:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !yoursite\.com [NC]
RewriteRule .*\.(txt|ico|jpg|jpeg|gif|png|bmp|js|css)$ - [F,NC,L]
yoursite.com在上述條件中用您的主域名替換您的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/397977.html
