View Single Post
Old 09-29-2012, 10:25 PM   PM User | #1
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
Looking for a rewrite exception

Hi i have a rewrite that helps stop my hotlinking problem but i need to make an exception for one of my sites, the sites are both on the same server.

here is the rewrite

Code:
#block images by direct url
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://xxxxxx.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://xxxxxx.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://xxxxxx.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.xxxxxx.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]
#end block
i need to make an exception for lets call it http://www.newsite.com

so if the referer is from http://www.newsite.com it is ok for them to link the image.

I have two sites, and i have members that belong to both sites, they want to be able to link images from the other site.

Thanks


Update: did some reading and it seems like i can just use the same thing but with an L option which will not execute the rest.

So if i use it like this i wonder if it will work.

Code:
#block images by direct url
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://newsite.com/.*$      [NC,L]  # If referer is from this site then stop the rewrite and allow image link
RewriteCond %{HTTP_REFERER} !^http://xxxxxx.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://xxxxxx.com$          [NC]
RewriteCond %{HTTP_REFERER} !^http://xxxxxx.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.xxxxxx.com$   [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]
#end block

UPDATE: well that totally blew up right in my face lol guess that doesnt work lol

Last edited by durangod; 09-30-2012 at 04:13 AM..
durangod is offline   Reply With Quote