防止使用.htaccess对包含特定字符串的PDF文件进行热链接


Prevent hotlinking PDF files with certain string in it with .htaccess

当用户未登录(使用Wordpress)并且以"restricted_"开头时,我想防止对pdf文件进行热链接。

目前我有以下.htaccess行:

#RewriteEngine On
#RewriteCond %{HTTP_REFERER} !^(.*)'.oegn'.at/ [NC]
#RewriteCond %{REQUEST_URI} !hotlink'.(pdf) [NC]
#RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
#RewriteRule .*'.(pdf)$ http://www.oegn.at/ [NC]

现在,这可以防止对每个.pdf文件进行热链接。我不知道怎样才能达到我的目标。

要检查文件,您可以执行下一步操作:

RewriteCond %{REQUEST_URI} ^/restricted_(.*)'.pdf
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ /current_file?=restricted_%1.pdf [R,L]

现在用你想要的替换我的rewriteRule。

如果你有任何问题,请告诉我。