Forum Moderators: phranque

Message Too Old, No Replies

.htaccess image-linking control

Allow some images and allow Google and Yahoo access

         

Maleville

11:31 pm on May 12, 2005 (gmt 0)

10+ Year Member



Hello.

Is this synthax correct?

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain\.net/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://216\.239\.(3[2-9]¦[45][0-9]¦6[0-3])\..*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://64\.233\.167\.104.*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://64\.233\.183\.104.*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://66\.102\.9\.104.*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://216\.109\.117\.135.*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://216\.109\.124\.98.*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://216\.239\.37\.104.*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://216\.239\.39\.104.*(www\.)?mydomain\.net/ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?world\.altavista\.com.*(www\.)?mydomain\.net/ [NC]
RewriteRule .*\.(gif¦ico¦jpe?g¦bmp¦wmf¦mid¦rmi¦rm¦ram¦au¦wav¦art¦img)$ - [F,NC]

sitz

10:26 am on May 13, 2005 (gmt 0)

10+ Year Member



it seems to be syntactically correct, yes. Now, whether it does what you want is another matter entirely. =)

For the record, syntax like this:


RewriteRule .*\.(gif¦jpg)$ - [F,NC]

or

RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain\.net/.*$ [NC]

Could be written better as:


RewriteRule \.(gif¦jpg)$ - [F,NC,L]

or

RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain\.net/ [NC]

IOW, don't use '.*' when it's not needed. As to whether the config you posted will do what you want, we'd need to know what you're trying to accomplish and see the type of Referer: headers you're getting to be able to answer that question.

Maleville

12:37 am on May 14, 2005 (gmt 0)

10+ Year Member



Thank's sitz for your answer.

- I want to give permission to www.mydomaine.com to link its own images.
- I want to give permission to Yahoo, Google cache and search Images to make links on mydomain.com
- Same thing for world.altavista which traduce my pages in others language.
- I found 216\.239\.(3[2-9]¦[45][0-9]¦6[0-3]) on [webmasterworld.com...]
Unfortunatly, the link [webmasterworld.com...] given by jdMorgan is not valid

I found also in my logs:

[google.com...] and so on.........
[google.com...] and so on.........
[google.fr...] and so on.........
[66.102.9.104...] and so on.........// Google
[64.233.183.104...] and so on.........// Google
[216.109.124.98...] and so on.........
[216.239.59.104...] and so on.........// Google
[216.239.37.104...] and so on.........//
[cc.msnscache.com...] and so on.........//MSN

Is it possible to replace all this IP (Google, Yahoo) with:
RewriteCond %(HTTP_REFERER) "!\/custom\?hl="
RewriteCond %(HTTP_REFERER) "!\/custom\?cof="
RewriteCond %(HTTP_REFERER) "!\/search\?hl="
RewriteCond %(HTTP_REFERER) "!\/search\?q=cache"
RewriteCond %(HTTP_REFERER) "!\/search\/cache\?ei="
RewriteCond %(HTTP_REFERER) "!\/translate_c\?hl="
RewriteCond %(HTTP_REFERER) "!\/search\?q=cache"
RewriteCond %(HTTP_REFERER) "!\/cache.aspx\?q="

as seen in [webmasterworld.com...]

But, probably we should write (for example):
RewriteCond %(HTTP_REFERER) "!\/custom\?hl=".*(www\.)?mydomain\.com/ [NC]

Maleville

10:53 pm on May 14, 2005 (gmt 0)

10+ Year Member



Certainly, I was drunk..........

RewriteCond %(HTTP_REFERER)!\/custom\?hl=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/custom\?cof=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/search\?hl=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/search\?q=cache.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/search\/cache\?ei=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/search\/cache\?p=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/search\?sourceid=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/search\/images\?p=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/images\?q=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/imgres\?imgurl=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/translate_c\?hl=.*(www\.)?mydomain\.com/ [NC]
RewriteCond %(HTTP_REFERER)!\/cache\.aspx\?q=.*(www\.)?mydomain\.com/ [NC]

Is it correct, now?

jdMorgan

11:58 pm on May 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No need to escape the "/" characters...

RewriteCond %(HTTP_REFERER) !\/search\/cache\?ei=.*(www\.)?mydomain\.com/ [NC]

can be written as

RewriteCond %(HTTP_REFERER) !/search/cache\?ei=.*(www\.)?mydomain\.com/ [NC]

Jim

Maleville

6:01 am on Jun 1, 2005 (gmt 0)

10+ Year Member



Seems to be good.

Thank you Jim.