Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,446
    Thanks
    275
    Thanked 32 Times in 31 Posts

    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 05:13 AM.

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,446
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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 02:10 AM.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    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.

  • Users who have thanked Inigoesdr for this post:

    durangod (10-02-2012)

  • #4
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,446
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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..

  • #5
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,446
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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 04:51 AM.

  • #6
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,446
    Thanks
    275
    Thanked 32 Times in 31 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •