我有一个网站,我试图限制用户访问根文件夹(即当用户键入https://example.com/img/image.png时显示被阻止的内容消息)。我在 .htaccess 上编写了以下代码:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^https://(\.)?domain.com [NC]
RewriteCond %{HTTP_REFERER} !^https://(\.)?domain.com.*$ [NC]
RewriteRule \.(gif|jpg|js|txt|png)$ /messageforcurious [L]
起初这很有效,但现在我的 html 文件上的元标记似乎找不到 og-image,显然是因为我刚刚写的限制。这是我的元标记。
<meta property="twitter:image" content="https://example.com/img/image.png">
有没有办法阻止用户直接访问图像而不影响元标签?
我尝试使用图像的相对位置:
<meta property="twitter:image" content="img/image.png">