View Single Post

  #2 (permalink)  
Old 11-08-2006
HansH
 
Posts: n/a
Default Re: .htaccess issues

<d362636@yahoo.com> schreef in bericht
news:1163019828.895883.209370@m7g2000cwm.googlegro ups.com...
> RewriteEngine on
> RewriteCond %{HTTP_REFERER} !^$
> RewriteCond %{HTTP_REFERER}
> !^http://s4.invisionfree.com/myforum/index.php/.*$ [NC]
> RewriteCond %{HTTP_REFERER}
> !^http://s4.invisionfree.com/myforum/index.php$ [NC]
> RewriteCond %{HTTP_REFERER} !^http://mydomain.com/.*$ [NC]
> RewriteCond %{HTTP_REFERER} !^http://mydomain.com$ [NC]
> RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com/.*$ [NC]
> RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com$ [NC]
> RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.mydomain.com [R,NC]
>
> Of course, the "myforum, mydomain" things are just representing my
> actual domain and InvisionFree board.
>
> Does this look odd to anyone? Other .htaccess files doing this don't
> seem to have everything listed twice, just slightly different on the
> very end of the url.

Right, by using the $ at the end the FULL url is cheched, the preseding .*
is a regex wildcard meaning any charachet ero or more times
So
RewriteCond %{HTTP_REFERER} !^http://mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain.com$ [NC]
can be shortened to
RewriteCond %{HTTP_REFERER} !^http://mydomain\.com [NC]
making it test the beginning og Urls only
Note thr \ before .: this way the dot is not a any-character wildcard, but a
literal dot.

> Now, like I said, this file already allows me to disable hotlinking
> from other sites, so I'm good there, it just won't seem to allow me to
> do *any* linking from my forum.

Your domain may have a prefix like in www.mydomain.com
let's prefix that part
RewriteCond %{HTTP_REFERER} !^http://([^\.]+\.)?mydomain\.com [NC]

> Another weird thing, my forum, when you
> hit the front page it shows up as:
> http://s4.invisionfree.com/myforum/index.php/
>
> But when you go to any area, or even back to the forum index after
> going into another area, it changes to this:
>
> http://z4.invisionfree.com/myforum/index.php/
> (the s changes to a z)

Probably some loadbalacing, just regex this prefix -and drop the full match-
too
RewriteCond %{HTTP_REFERER} !^http://([^\.]+\.)?invisionfree\.com/myforum/
[NC]


All in all try these untested lines
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([^\.]+\.)?invisionfree\.com/myforum/
[NC]
RewriteCond %{HTTP_REFERER} !^http://([^\.]+\.)?mydomain\.com [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F]


HansH