1 頁 (共 1 頁)

apache2 Hotlink Protection (Image theft Block Access)

發表於 : 2026-08-03, 06:51
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