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

Thread: .htaccess

  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    161
    Thanks
    2
    Thanked 0 Times in 0 Posts

    .htaccess

    I want to use .htaccess to block hotlinking images, however I want to allow more than one domain to use the images (I have more than one site that I want to use them on) how do you do that?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    the Netherlands
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Haven't tested this, but it should look like this:

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !first.domain.com [NC]
    RewriteCond %{HTTP_REFERER} !scnd.another.domain [NC]
    RewriteRule \.(gif|jpg)$ - [F]

    Greetz, Chris
    My Website
    010100010011110101110100011011110111000001101000

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    161
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Originally posted by chrisvmarle
    Haven't tested this, but it should look like this:

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !first.domain.com [NC]
    RewriteCond %{HTTP_REFERER} !scnd.another.domain [NC]
    RewriteRule \.(gif|jpg)$ - [F]

    Greetz, Chris
    Thanks, it can be http://www.domain1.com or http://domain1.com I take it both need listing. Also I take it I can add more entries it's not limited to two for any reason is it?

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    the Netherlands
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, both need to be listed and it's not limited to just two lines
    My Website
    010100010011110101110100011011110111000001101000

  • #5
    New to the CF scene
    Join Date
    Nov 2003
    Location
    Chicago, IL
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm curious if a variation of that can be used to block a hyperlink from a foreign site to mine.

    Can I re-direct a user coming from a specific site?

  • #6
    Regular Coder
    Join Date
    Nov 2002
    Posts
    161
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yes it can, the script is used here to block access to JPG and GIF files, just set it up as HTM, HTML, PHP or whatever the file type is. Sites linking to you will get your 403 (forbidden) page, customise that to whatever you want. If you want to be real smart you could put a $HTTP_REFERER script in and redirect users to different pages depending on where the foreign link was from.

    Just out of interest though, why do you want to stop other sites from linking to you?


  •  

    Posting Permissions

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