我试图拒绝直接访问和跨域访问我的网站,所以我试图使用通配符访问。
只有我的网站和受信任的域名可以访问我的资产,如图像,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]我的资产仍未阻止直接访问和跨域访问。
发布于 2021-12-30 10:48:19
你可以用这个:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !yoursite\.com [NC]
RewriteRule .*\.(txt|ico|jpg|jpeg|gif|png|bmp|js|css)$ - [F,NC,L]在上述条件下,将yoursite.com替换为您的主域名。
https://stackoverflow.com/questions/70530354
复制相似问题