如何通用的.htaccess prevent热链接链接、htaccess、prevent

2023-09-02 00:47:13 作者:浅吟゛花非花的流年

下面code正常工作:

 的RewriteCond%{HTTP_REFERER} ^ HTTP://superwebx.com/.*$ [NC]
重写规则* 。(JPE G | GIF | BMP | PNG |瑞士法郎|?CSS)$  -  [F]
 

但我想打一个通用脚本为我服务的几个网站我管理,但没有试图让

 的RewriteCond%{HTTP_REFERER} ^ HTTP://%{HTTP_HOST} /.*$ [NC]
重写规则* 。(JPE G | GIF | BMP | PNG |瑞士法郎|?CSS)$  -  [F]
 

解决方案

很老的一个,但这里是你的回答:

 的RewriteCond%{HTTP_HOST} @@%{HTTP_REFERER} ^([^ @] *)@@ HTTPS://  1 /.*
 
WordPress修改固定链接后301的重定向方法

The following code works fine:

RewriteCond %{HTTP_REFERER} !^http://superwebx.com/.*$ [NC]
RewriteRule .*.(jpe?g|gif|bmp|png|swf|css)$ - [F]

but I want to make a generic script serve me for several sites I manage, but fails try to get

RewriteCond %{HTTP_REFERER} !^http://%{HTTP_HOST}/.*$ [NC]
RewriteRule .*.(jpe?g|gif|bmp|png|swf|css)$ - [F]

解决方案

Very old one, but here's your answer:

RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} !^([^@]*)@@https?://1/.*