Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite

how to check it's on?

         

ozon59

6:34 am on Sep 25, 2005 (gmt 0)

10+ Year Member



Hello everybody,
I got two variations for a hotlink preventer:

1)
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com\.com [NC]
RewriteRule \.(gif¦jpe?g¦bmp¦wm[av]¦png¦mpe?g¦avi¦mp3¦css¦js)$ - [NC,F]

2)
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif¦jpg¦js¦css¦mp3)$ [mydomain.com...] [R,L]

Both fail to work for me - #1 was suggested from my webhost's support. Is there a simple way to check if mod rewrite is working/active at all?

thx for thoughts :)

jdMorgan

7:33 pm on Sep 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ozon59,

Welcome to WebmasterWorld!

Try a simple rule first:


Options +FollowSymLinks
RewriteEngine on
RewriteRule ^test\.html$ http://www.google.com [R=301.L]

If you install this and then request the page /test.html from your server, your browser should be redirected to Google.

As always, flush your browser cache after making *any* change to your access control code.

I like your code example #1 better than #2.

Jim

ozon59

9:07 pm on Sep 25, 2005 (gmt 0)

10+ Year Member



jdMorgan

Thank you, I tried your script and it works.
But why is my code below not working?
The hotlink preventer seems to prevent nothing (last lines of code) - I still can load image files by direkt linking instead of seeing my nice photo :(
maybe my syntax is at fault? I am pulling my hairs out :) (Mydomain.com is replaced with my real domain in the original script)

<Files .htaccess>
deny from all
</Files>
Options -Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^CherryPicker [OR]
RewriteCond %{HTTP_USER_AGENT} ^Crescent [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*NEWT [OR]
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^[Ww]eb[Bb]andit [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebEMailExtrac.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^NICErsPRO [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR]
RewriteCond %{HTTP_USER_AGENT} ^Microsoft.URL [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^LinkWalker [OR]
RewriteCond %{HTTP_USER_AGENT} ^sitecheck.internetseer.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ia_archiver [OR]
RewriteCond %{HTTP_USER_AGENT} ^DIIbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^psbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailCollector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif¦jpg¦js¦css¦mp3)$ [mydomain.com...] [R,L]

ozon59

11:04 pm on Sep 25, 2005 (gmt 0)

10+ Year Member



Funny, Funny!

When I test my hotlink from [another site] below it works as desired - angryman.gif pops up.

When I test it from my place or ask my wife to test the hotlink from her office's place (different isp) the hotlink prevention does not work.

My webspace is in the USA and I am in Australia - what is going on? ideas?

[edited by: jdMorgan at 4:33 am (utc) on Sep. 26, 2005]
[edit reason] No URLs, please. See TOS. [/edit]

jdMorgan

4:35 am on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From my post above:
As always, flush your browser cache after making *any* change to your access control code.

If your browser has a cached copy of the image, then it will serve the image from cache, and will not send the request to your server. If the request is not sent to your server, then your code on your server cannot affect the request.

Jim

ozon59

5:56 am on Sep 26, 2005 (gmt 0)

10+ Year Member



Jim,

thx, done this b4, cleared cache on Mozilla and IE6 several times but still no joy - it seems not to work from our place (home and office downtown). It just loads any file u want.

Using any ONLINE IMAGE HOTLINKING CHECKER and it works just fine. Help me to untie this knot :)

ozon59

6:32 am on Sep 26, 2005 (gmt 0)

10+ Year Member



Ah, I think I found the culprit!
It only works if the request is comming through a web page(link).

It does not work when u plain paste the direct link into the url bar of the browser.

Is this correct and designed this way? - Mean, I would have thought that paste-into-browser will be blocked?!

jdMorgan

2:33 pm on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, if you analyze your results keeping in mind the phrase "hot-link" and "Referrrer" it should become clear -- A URL typed into a browser has no referrer, so the HTTP_REFERER header is not sent to the server. Therefore, the request will not be blocked.

Access control by referrer is not a 100% solution. It's advantage is that it is easy. More sophisticated cookies-based solutions are possible, but they involve a lot more work and complexity. Plus, they won't work if the visitor has disabled cookies in his/her browser.

There are many threads [google.com] here that discuss this situation. Simple referrer-based access control is often 'good enough' because it makes the sites that link to your images look broken, at least most of the time. This causes the sites that link to your site (or those that attempt to do so) to decide that it's not a good idea.

Jim