referrer "-", how to prevent from that kind of cal

Fix it!!

referrer "-", how to prevent from that kind of cal

Postby Guest » Thu Nov 18, 2004 2:33 pm

hello,
i use mod_rewrite to prevent directilking to my photo gallery images:

Code: Select all
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?fotogalerie.pl(/)?.*$     [NC]
RewriteCond %{HTTP_REFERER} !=""
RewriteRule .*\.(jpg)$ http://fotogalerie.pl/fg1.GIF [R,NC]


..this worki fine for all webpages.

BUT if we call file url direct from browser ADDRESS BAR it doesn't work - in that case HTTP_REFERRER in Apache log looks like: "-"

how to config .htacces to detect HTTP_REFERRER marked as "-"?
Guest
 

Postby Caterham » Fri Dec 10, 2004 3:05 pm

Code: Select all
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?fotogalerie.pl(/)?.*$     [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.jpg$ http://fotogalerie.pl/fg1.GIF [R,NC]
I think with ^$ (empty referer) :P
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sun May 01, 2005 11:59 am

it works!
thank you
Guest
 

hotlinking html pages

Postby billythekid » Tue Sep 06, 2005 11:17 am

This mod rewrite tags work great for images, but how can i do this for .html pages. I have some html pages that should only be accessed from internal links, but not from outside.
This is what i have so far and its working great for images, cgi, php, and a couple more:

RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} !^http://%{HTTP_HOST}/^$ [NC]
RewriteRule .*\.(php|cgi|pl|gif|jpg|swf|htm$)$ http://%{HTTP_HOST}/main.html [R=301,L]

Can someone tell me how to make this work for .html files as well. when i add the html extention, i get a overload error. When i add htm$, it just only stops .htm pages but not .html

I search and search this forums, bu no luck. So, i had to bug you guys; sorry!

I hope someone can help this newbie.
billythekid
 
Posts: 4
Joined: Tue Sep 06, 2005 11:09 am

Postby seomike » Tue Oct 25, 2005 7:28 am

RewriteRule .*\.(php|cgi|pl|gif|jpg|swf|htm$)$ http://%{HTTP_HOST}/main.html [R=301,L]

Just use

RewriteRule .*\..*$ http://%{HTTP_HOST}/main.html [R=301,L]

That will nab every extension known to man and then some :)
seomike
 
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas

Postby billythekid » Wed Oct 26, 2005 10:11 am

seomike wrote:RewriteRule .*\.(php|cgi|pl|gif|jpg|swf|htm$)$ http://%{HTTP_HOST}/main.html [R=301,L]

Just use

RewriteRule .*\..*$ http://%{HTTP_HOST}/main.html [R=301,L]

That will nab every extension known to man and then some :)


Thanks seomike, but when i do that it goes into an infinite loop.
Any suggestions?
billythekid
 
Posts: 4
Joined: Tue Sep 06, 2005 11:09 am

Postby seomike » Wed Oct 26, 2005 11:43 am

RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/$ [NC]
RewriteRule .*\..*$ http://www.yourdomain/main.html [R=301,L]


There was an extra ^ in the rewritecond I think it was screwing up the mix. try this.
seomike
 
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas

Postby billythekid » Wed Oct 26, 2005 4:19 pm

seomike wrote:RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/$ [NC]
RewriteRule .*\..*$ http://www.yourdomain/main.html [R=301,L]


There was an extra ^ in the rewritecond I think it was screwing up the mix. try this.


Thats an enfinite loop too, however that does help me know what couses the loop. Apperently because the "main.html" has the ".html" extention, its rewriting over and over. so, when i take out the "main.html" it works just fine.

RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/$ [NC]
RewriteRule .*\..*$ http://www.yourdomain/ [R=301,L]

Is there anyway around this? I don't have much, but i can send about $20 via paypal to whoever tells me how.
billythekid
 
Posts: 4
Joined: Tue Sep 06, 2005 11:09 am

Postby billythekid » Wed Oct 26, 2005 5:07 pm

well, i figured it out. just in case anyone has the same problem:


RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/ [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /main\.html [NC]
RewriteRule .*\..*$ http://www.domain.com/main.html [R=301,L]
billythekid
 
Posts: 4
Joined: Tue Sep 06, 2005 11:09 am


Return to Security with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 16 guests

cron