Talha Choudary
Talha Choudary

Reputation: 1

.htaccess Hotlink prevention not working with [F], works with /403.html

I was trying to implement hotlink prevention on my site using .htaccess, but I encountered some issues.

I first tried this rule:

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?siteName\.com/.*$ [NC]

RewriteRule \.(gif|jpg|jpeg|mp3|png|pdf|zip)$ - [F]

It didn't work.

Then I tried this

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?siteName\.com/.*$ [NC]

RewriteRule \.(gif|jpg|jpeg|mp3|png|pdf|zip)$ - [F,L] 

it still didn't work. But when I try this:

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?siteName\.com/.*$ [NC]

RewriteRule \.(gif|jpg|jpeg|mp3|png|pdf|zip)$ - /403.html [F,L]

It worked. I don't know how by redirecting it can work. I am learning all by myself so if here someone can help me.

Upvotes: 0

Views: 15

Answers (0)

Related Questions