CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Apache configuration (http://www.codingforums.com/forumdisplay.php?f=69)
-   -   Looking for a rewrite exception (http://www.codingforums.com/showthread.php?t=274730)

durangod 09-29-2012 10:25 PM

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

durangod 10-02-2012 04:11 AM

Ok can someone at least tell me why when i put the original in the root domain htaccess file it affects all the other add on domains. If they have their own .com the htaccess from the root domain should not affect it correct.

Do i need to add all all my add on domains on that cpanel account to that rewrite above?

Inigoesdr 10-02-2012 06:29 PM

Quote:

Originally Posted by durangod (Post 1275462)
Ok can someone at least tell me why when i put the original in the root domain htaccess file it affects all the other add on domains. If they have their own .com the htaccess from the root domain should not affect it correct.

It depends on your server configuration and the folder structure. If all of your domains are aliases that point to the same folder then they will all look at the same .htaccess.

Quote:

Originally Posted by durangod (Post 1275462)
Do i need to all all my add on domains on that cpanel account to that rewrite above?

Yeah, those other items are exceptions. It's basically saying:
Code:

If          the referrer    is not "http://xxxxxx.com" using a case-insensitive comparison
RewriteCond %{HTTP_REFERER} !^http://xxxxxx.com$      [NC]

Send a forbidden status
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]

Though, the RewriteRule will usually have an L flag to prevent any further rules from executing.

durangod 10-02-2012 09:58 PM

Thanks you so very much, it makes sense now. I have been reading the article on this forum of how to do this as well. You really make it clear and i thank you very much.. :)

durangod 10-03-2012 02:15 AM

well it didnt work and not sure why.

here is what i have, the problem all images from all the sites themselves get blocked including the index page and even this one gets blocked

Code:

http://www.site3.com/styles/ca_black/imageset/logo.jpg

i copied and pasted this in each of the domains htaccess files.



Code:



#block images by direct url all sites listed
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://site1.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://site1.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://site1.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site1.com$      [NC]
#
RewriteCond %{HTTP_REFERER} !^http://site2.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://site2.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://site2.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site2.com$      [NC]
#
RewriteCond %{HTTP_REFERER} !^http://site3.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://site3.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://site3.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site3.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]
#end block

UPDATE i tried using F,NC,L and same result. Maybe i need to use AND or the OR to combine them.

durangod 10-03-2012 05:09 AM

ok i think i may have found it, the site is a phpbb site and the gallery has its own htaccess set up for each image dir, i finally thru searching all the folders found the image that kept comming up that said not auth. So thats where it is comming from, not Cpanel and not the server, the phpbb gallery is blocking it.

So at least i know where to research.

Thanks for your help your awesome peace :)


All times are GMT +1. The time now is 05:08 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.