apache2 Hotlink Protection (Image theft Block Access)

回覆文章
Brave Ye
系統管理員
文章: 5351
註冊時間: 2025-11-08, 13:32
聯繫:

apache2 Hotlink Protection (Image theft Block Access)

文章 Brave Ye »

nano /var/www/html/.htaccess

代碼: 選擇全部

<IfModule mod_rewrite.c>
  RewriteEngine on
  # Allow requests with no referrer (direct access, firewalls, etc.)
  RewriteCond %{HTTP_REFERER} !^$
  # Allow requests from your own domain (replace 'yourdomain.com')
  RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.?)?yourdomain\.com/.*$ [NC]
  # Block common image formats
  RewriteRule \.(gif|jpe?g|png|bmp|webp)$ - [F,NC,L]
</IfModule>
sudo a2enmod rewrite
sudo systemctl restart php8.5-fpm
sudo systemctl restart apache2
回覆文章

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客