apache2 Hotlink Protection (Image theft Block Access)
發表於 : 2026-08-03, 06:51
nano /var/www/html/.htaccess
sudo a2enmod rewrite
sudo systemctl restart php8.5-fpm
sudo systemctl restart apache2
代碼: 選擇全部
<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 systemctl restart php8.5-fpm
sudo systemctl restart apache2