0

Right now I want to redirect users who open up a direct image thats embedded in another site.

livememe does this perfectly by having http://www.livememe.com/36opcf5.jpg redirect to http://www.livememe.com/36opcf5 even though the direct image url is embedded within another site.

Now I'm trying to acomplish the same thing and this is what I have so far:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?reddit.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?tumblr.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} ^$ 
RewriteRule ^i/([a-zA-Z0-9]+)\.(jpe?g|JPE?G)$ /r/$1 [R]

Now from what I understand is that I'm allowing these websites to embed my images in their site but I'm redirecting them if they access the url directly without being refered.

For example on my site I have images located like this: http://mysite.com/i/0b1be.JPG

While the article is located: http://mysite.com/r/0b1be

The redirect works but I'm still failing because you can still access the direct image if you followed it from any of the websites allowed.

4

2 回答 2

0

您可以尝试添加此条件:

RewriteCond %{HTTP_ACCEPT} !^(.*)image(.*)$ [NC]
于 2013-07-27T19:10:54.283 回答
0

你可以试试这段代码:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?(reddit|tumblr|facebook|mysite).com/.*$ [NC]
RewriteRule ^i/([a-zA-Z0-9]+)\.(jpe?g|JPE?G)$ /r/$1 [R]
于 2013-07-21T05:46:39.183 回答