Forum Moderators: phranque

Message Too Old, No Replies

Optimization and stuff

         

Namjies

2:29 am on May 17, 2010 (gmt 0)

10+ Year Member



I got some questions for you jd. About leech protect and specific domain usage.
(I REMOVE THE FIRST H OF the http:// SO IT WOULDN'T CREATE LINKS)
~~~~~~~~~~~~~~~~~~~~~~

First with domain, I was using this


RewriteCond %{HTTP_HOST} !^(arcade\.example\.com)?$
RewriteRule ^(.*)$ ttp://arcade.example.com/$1 [R=301,L]


But I heard some clients might not return an HTTP_HOST. I've seen these solutions


RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^(arcade\.example\.com)?$
RewriteRule ^(.*)$ ttp://arcade.example.com/$1 [R=301,L]

Or this (that one is from you)
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^(arcade\.example\.com)?$
RewriteRule ^(.*)$ ttp://arcade.namworld.com/$1 [R=301,L]


And I was wondering why a dot. That's not such an important matter, but I'd like to know.


~~~~~~~~~~~~~~~~~~~~~~~~~~~
Second, leech protect. I was wondering why it didn't work when I was escaping the dots (or why I actually don't have to escape those dots in the http referer.


RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://arcade.example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://[a-z]+.facebook.com/.*$ [NC]
RewriteRule .*\.png$ ttp://www.example.com/leech.png [R,L]


I also tried to change the rewrite rule as specified in another post you made from


RewriteRule .*\.png$ ttp://www.example.com/leech.png [R,L]

to your suggestion

RewriteRule \.(gif夸pg夸peg如ng存wf)$ ttp://www.example.com/leech.png [R,NC]


but for some reason, it doesn't work. \.png$ alone seems to work, but not multi arguments like \.(png存wf). And I was wondering why there's no token in front of the .extension
Shouldn't there be a (.*) (I know it's inefficient) or some kind of [a-z]* token in front for it to work?

The kind of omissions I don't really understand yet.

~~~~~~~~~~~~~~~~~~~~~~~~~~
Finally, suppose I'd want a string comprised of [a-z] AND dashes/numbers (like the-file-name-2.php), I'm not sure how to write a multi-value yet. would [a-z0-9-] work? It seems odd to add the dash alone, out of a range.

Thanks

[edited by: engine at 4:59 pm (utc) on May 17, 2010]
[edit reason] Please use example.com [/edit]

Namjies

3:36 am on May 17, 2010 (gmt 0)

10+ Year Member



Just found this on askapache.com

## REDIRECT HOTLINKERS ###
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(subdomain\.)?domain.tld/.*$ [NC]
RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ [google.com...] [R]


I'll try it tomorrow to see if it works. Got to get up early.

g1smd

10:01 am on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's multiple problems with the last code.

The . simply means "is something" or "not blank".

With this code:
RewriteCond %{HTTP_HOST} !^(arcade\.example\.com)?$
the question mark caters for blank hostname.

Your [R] flag generates a 302 redirect.

The
.*\.png$
pattern requires many back off and retry attempts to match. Use
\.png$
which is properly end-anchored. Start anchor not required.

The forum used to break the pipe symbol:
\.(gif夸pg夸peg如ng存wf)$
so you'll need to edit the pipe symbol to be the correct pipe symbol.

[edited by: engine at 5:00 pm (utc) on May 17, 2010]
[edit reason] examplified [/edit]

Namjies

4:39 pm on May 17, 2010 (gmt 0)

10+ Year Member



hey, thanks. Excellent and fast.

Good to know that without a start anchor, I can put only the end of the url.

But...
the image is redirected to an leech.png file. It doesn't work and show the actual image. I clear cache, refresh and it shows the leech.png ... But then, if I wait 2-3 minutes before refreshing, it RELOADS the image instead of leech.png and I have to empty the cache again to get leech.png to appear again.

Is it possible that some browsers don't accept the redirect notice on a image or mess with it and download the real image instead, where if I'd have used
\.(png|gif)$ - [F]
With the forbidden, server would simply deny access to the file?

jdMorgan

7:15 pm on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the image is cached, then you'll see the image from your cache and no request will be sent to your server. Since this eliminates the extra bandwidth, and (for a normal user) the 'real' image won't ever be cached, you basically are seeing the expected behaviour, and shouldn't worry about it.

This is why we tell people that if you want accurate test results of redirects, rewrites, and 403 responses, you must clear your cache... every time before you test.

Jim