Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
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
Old 10-02-2012, 04:11 AM   PM User | #2
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
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?

Last edited by durangod; 10-03-2012 at 01:10 AM..
durangod is offline   Reply With Quote
Old 10-02-2012, 06:29 PM   PM User | #3
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
Quote:
Originally Posted by durangod View Post
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 View Post
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.
Inigoesdr is offline   Reply With Quote
Users who have thanked Inigoesdr for this post:
durangod (10-02-2012)
Old 10-02-2012, 09:58 PM   PM User | #4
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
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 is offline   Reply With Quote
Old 10-03-2012, 02:15 AM   PM User | #5
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
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.

Last edited by durangod; 10-03-2012 at 03:51 AM..
durangod is offline   Reply With Quote
Old 10-03-2012, 05:09 AM   PM User | #6
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
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
durangod is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:36 PM.


Advertisement
Log in to turn off these ads.