...

View Full Version : .htaccess



Dalziel
10-31-2003, 09:52 PM
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?

chrisvmarle
11-02-2003, 01:03 AM
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

Dalziel
11-02-2003, 04:18 PM
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?

chrisvmarle
11-02-2003, 04:58 PM
Yes, both need to be listed and it's not limited to just two lines :)

TEKKY
11-24-2003, 07:59 PM
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?

Dalziel
11-25-2003, 01:30 AM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum