Some time ago, I slightly changed the rule for ppl redirection, which directly refers to my image in images, not to them.
for example, a person visiting www.mysite.com/i/asdf.jpg to www.mysite.com/pic/asdf
this is the rewrite rule that I used:
location /i/image_(\d+).(gif|jpg|jpeg|png)$ { root /home/mysite/public_html; valid_referers www.example.com mysite.com; if ($invalid_referer) { rewrite ^ http://www.example.com/pic/$1 permanent; } }
I created a subdomain of the "i" directory that contains all the images. so its kind of thsi now http://i.mysite.com/
Is it possible to do a rewrite as described above, so if a file directly refers to another referrer, it will fall into the same rewrite rule?
thanks:)
UPDATE: now using this:
server { access_log off; error_log logs/vhost-error_log warn; listen 80; server_name i.imgzzz.com; root /home/imgzzz/public_html;
Htaccess overwrites:
RewriteBase / Options +FollowSymlinks #RewriteEngine on rewritecond %{http_host} ^imgzzz.com [nc] rewriterule ^(.*)$ http://www.imgzzz.com/$1 [r=301,nc] RewriteCond %{HTTP_REFERER} !^http://(www\.)?imgzzz.com/.*$ [NC] RewriteRule i/image_(\d+)\.(jpg|jpeg|gif) pic/$1 [L] RewriteRule ^pic/([0-9]+)/{0,1}$ view.php?name=$1 [QSA,L] RewriteRule ^pic/full/([0-9]+)/{0,1}$ view-f.php?name=$1 [QSA,L] RewriteRule ^pic/([0-9]+)/feature/$ view.php?name=$1&pop=1 [QSA,L]
source share