Who wanted .htaccess help? Here it is.. (part 1)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fusionx
    Confirmed User
    • Nov 2003
    • 4618

    #1

    Who wanted .htaccess help? Here it is.. (part 1)

    Here's a fairly comprehensive explanation blocking hotlinkers using .htaccess and mod_rewrite with reasonably full explanations. Please read it carefully - almost every little bit matters!

    Obviously, your server must have mod_rewrite. I think they all do.

    Keep in mind - servers can be different based on the version of Apache, various mods installed, etc. If you use any part of this, test it out carefully. In some cases, where I have something like ".*", you might need to use "(.*)" in your specific server configuration.

    I'd recommend creating a new subdirectory, drop in some content and new subdirectories, and test in there until you are sure everything works.

    First, I want to point out that the Apache will start looking for .htaccess files in the root directory, then in each directory it has to follow to find the target file. If you were linking to www.domain.com/images/banners/banners.jpg, Apache would look for .htaccess in /, /images, and /images/banners, and will process each one it finds. This is pretty bad when you want to leave a few directories open for hotlinking. The answer to this is the AllowOverride directive in the Apache config files. Every server I've used has had the AllowOverride set correctly in the apache configs, and this can be a very good thing. This basically says "let this specific .httaccess file control this specific directory". If it finds one, it does not merge and process any others. If your server does not have this directive set this way, you can ask them to do it, or, be ready to manage your htaccess files very carefully! You can put .htaccess files in every directory that simply redirect requests for missing files (see the ErrorDocument directives later on), or put hotlink blocking .htaccess files in each directory that matters, eg; images/*, privatesPics/*, whatever.

    Assuming you will block hotlinking throughout your web site (and the AllowOverride directive is set correctly), here's how to leave a subdirectory open. Create an .htaccess file in the subdirectory you want to leave open, and type out this single line:

    Options -Indexes
    RewriteEngine On

    Save the file, and you are done. This tells Apache to disallow direct browsing of that subdirectory, and the "empty" RewriteEngine On overrides any previous matching conditions, thus opening it up for the world to hotlink.

    You can comment your .htacess with the "#" symbol. If you do use comments in your .htaccess files, only start them in the very first column, and keep them on one line - otherwise you'll fill your server logs with useless error messages.

    Since it's hard to write out this info and keep the .htacess file neat and clean, I'll forgo comments, and just list the whole thing again at the end.

    All lines in your .htaccess need to be one line - don't let individual lines break. That may happen as you read this; every entry shoul;d be on it's on line for real-world use.

    This turns off index browsing for all subdirectories from here and below:

    Options All -Indexes

    this sets the order of handling requests. I allow all, and deny specific
    IP addresses as needed:

    order allow,deny
    deny from 84.24.157.106
    deny from 24.30.156.64
    deny from 213.224.83.
    deny from 62.194.58.230
    deny from 65.32.247.133
    deny from 24.110.101.138
    deny from 130.161.13.62
    allow from all

    You can also reverse the order and have something like:

    order deny, allow
    84.24.157.106
    24.30.156.64
    213.224.83.
    62.194.58.230
    65.32.247.133
    24.110.101.138
    130.161.13.62
    allow from all

    That denies by default, so you don't need the "deny from". I leave it in so I know exactly what's happening.

    Tell Apache to follow symbolic links:

    Options +FollowSymLinks

    This is where the fun begins!

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.primanudes\.com
    RewriteRule (.*) http://www.primanudes.com/$1 [R=permanent,L]

    Turn on the Rewrite engine. This will allow Apache to manipulate the urls, allowing you to block referers, redirect bad guys, and a lot of other fun things.

    RewriteEngine on

    RewriteCondition. Here, we tell Apache what to look for. In this example, I'm saying "if the host name being requested does not include exactly www.primanudes.com" do something. The something is in the next line.

    RewriteCond %{HTTP_HOST} !^www\.primanudes\.com

    Assume for the moment you hit my site with just http://primanudes.com. This triggers that condition so the next line, starting with rewriterule, is activated:

    RewriteRule (.*) http://www.primanudes.com/$1 [R=permanent,L]

    The above line tells the RewriteEngine to literally rewrite the URL for that browser request, which conducts a redirect to the full URL, including "www". The [R=permanent, L] tells Apache this is a Redirect, and to make it permanent, and the L tells Apache this is the Last rule in this block.

    The $1 says "keep whatever was after the matched string in the initial request". Since we matched on "primanude.com", everything after that is retained and tacked back onto the end of the new URL. That way, someone going to http://primanudes.com/text.html won't lose the "text.html" part when the redirect happens.

    Why is this helpful? Google treats http://primanudes.com and http://www.primanudes.com as different addresses from purposes of page rank, as will many utilities and server functions. With google, this has the effect of making sure all page rank "funnels" to the correct URL.

    That's it for rewriting a partial URL to a full URL. You can do a lot more than this, but I'll leave that up to you to research and learn about.

    This next block disallows hotlinking for specific refering sites. EG; if the browser hit a link from one of the matching URLs, they don't get what they expect.

    First, we turn the RewriteEngine on again, see if the requests match a couple different patterns, then see if the request contains any images. If it matches, and is a request for any of the listed images, drop the request completely.

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} .*fusker*.*$ [NC]
    RewriteCond %{HTTP_REFERER} .*usefulidiot*.*$ [NC]
    RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://www.primanudes.com/hotlink/hotlink.jpg [F,NC]

    Remember, that last line should not be split across two lines.

    The conditions (RewriteCond) tell Apache to check the referer string sent by the browser. In both of these cases, a referer containing "fusker" or "usefulidiot" will match. You can put any part of a URL in here and it will be blocked. Be careful with this!! Imagine what would happen if you put ".com" here - Apache would drop any request with a referer containing ".com" - that's bad for business!

    Let's looks at the lines more closely.

    RewriteCond %{HTTP_REFERER} .*fusker*.*$ [NC]

    This simply says match any referer with the word "fusker" in it. The ".*" at the start says "any number of any charachters in followed by 'fuscker'". The *.* says "any pattern of "." and any other text as well". The "$" says "end of line". The [NC, OR] tells Apache to not consider the case of the letters in the string. Fusker, FUSker, and FUSKER will be treated the same.

    RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://www.primanudes.com/hotlink/hotlink.jpg [F,NC]

    The RewriteRule used here says if the request is for an image, return an image of my choice! My "hotlink.jpg" could be *******, goatse, or anything equally nasty. I prefer to use a watermarked image with my domain name. It's semi-free advertising.

    Again, the [F,NC] tells Apache this is the final rule, and, to not consider case in the request. JPG = jpg, etc. The part in the "()"s is pretty cool. The pipe symbol "|" means "OR", to Apache looks for jpg OR gif OR jpeg, etc.

    This next block turns off the ability for others to hotlink your images throughout the entire site (assuming you place an .htacess file with this code in the root directory of your site).

    (continued in part 2) ...
  • fusionx
    Confirmed User
    • Nov 2003
    • 4618

    #2
    part 2, continued....

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://google.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.google.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com/images/banners/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com/images/banners$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/friends/banners/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/friends/banners/$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/banners/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/banners/$ [NC]
    RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ - [F,NC]

    In the above example, I've told Apache to let a number of refering URLS grab images. Any URL that isn't matched will not be able to grab the images. Remember, the "^" says NOT, so if the refering URL is NOT http://www.google.com, etc, it's a match. I've listed each url in a couple different ways. There ae better ways to write this that will combine the multiple versions into one single matching condition - I'm just lazy tonight.

    Here's an example:

    RewriteCond %{HTTP_REFERER} !^http://(www\.|kinzie-kenner\.|tiffany-paris\.|ronni-tuscadero\.|ftv-girls\.)?primanudes.com(/)?.*/.*$ [NC]

    That says www. OR kinzie-kenner. OR tiffany-paris. OR ronni-tuscadero. OR ftv-girls. followed by hottiesusa.com, followed by anything. The www. is self-explanatory. The others are possible sub-domains. You can also simply say:

    RewriteCond %{HTTP_REFERER} !^.*primanudes.com.* [NC]

    I like writing them out so I know exactly what is covered and what is not.

    To continue:

    RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ - [F,NC]

    If anything matched in the RewriteConditions, enfocre the RewriteRule. This time, I'm just dropping the request rather than returning my hotlink.jpg image. The "-" where the URL was in the previous ReWriteUrl means "don't do anything here".

    Why do I leave Google in here? Well, this allows Google to fully spider your images. You can get creative with your directory structures and only let google spider thumbs, maybe, or have a special directory of images you want to get listed in Google - that's up to you.

    You can add entries for any URL you like. If you want to display banners on www.thisothersite.com, where the images are on www.myfirstsite.com, just add an entry explicitly allowing www.thisothersite.com.

    Finally, ErrorDocument tells Apache what to do when certain response codes are encountered. I just redirect the browser to my custom 404.html page (a 404 error is generated when a file can not be found).

    If you wanted to sell your 404 traffic, just change the URL to something appropriate.

    ErrorDocument 400 http://www.primanudes.com/404.html
    ErrorDocument 403 http://www.primanudes.com/404.html
    ErrorDocument 404 http://www.primanudes.com/404.html
    ErrorDocument 500 http://www.primanudes.com/404.html
    ErrorDocument 501 http://www.primanudes.com/404.html
    ErrorDocument 503 http://www.primanudes.com/404.html

    A special note on redirecting 404 errors. If you want to send people back to your home directory when a file can't be found, and put a line in your .htaccess that is similar to:

    ErrorDocument 404 http://www.primanudes.com/index.html

    make DAMN SURE you have an index.html file in the root directory. If you don't, the request will gert looped infinately. eg; apaches says it can't find the default doc, index.html, so it will redirect the request to, you guessed it, index.html. Over and over. Until the browser crashes.

    Here's the promised complete .htaccess file:

    #start
    Options All -Indexes

    order allow,deny
    deny from 84.24.157.106
    deny from 24.30.156.64
    deny from 213.224.83.
    deny from 62.194.58.230
    deny from 65.32.247.133
    deny from 24.110.101.138
    deny from 130.161.13.62
    allow from all

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.primanudes\.com
    RewriteRule (.*) http://www.primanudes.com/$1 [R=permanent,L]

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} .*fusker*.*$ [NC]
    RewriteCond %{HTTP_REFERER} .*usefulidiot*.*$ [NC]
    RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ - [F,NC]


    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://google.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.google.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com/images/banners/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://primanudes.com/images/banners$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/friends/banners/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/friends/banners/$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/banners/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.primanudes.com/banners/$ [NC]
    RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ - [F,NC]

    ErrorDocument 400 http://www.primanudes.com/404.html
    ErrorDocument 403 http://www.primanudes.com/404.html
    ErrorDocument 404 http://www.primanudes.com/404.html
    ErrorDocument 500 http://www.primanudes.com/404.html
    ErrorDocument 501 http://www.primanudes.com/404.html
    ErrorDocument 503 http://www.primanudes.com/404.html
    #end

    There's a lot more you can do with .htacess files and mod_rewrite. Here's the Apache documentation for mod_rewrite:

    http://httpd.apache.org/docs/mod/mod_rewrite.html

    Comment

    • fusionx
      Confirmed User
      • Nov 2003
      • 4618

      #3
      Peeps - do me a favor and bump this thread if you read it and like it. It'll fall off the page too fast otherwise. Other people can use this info.

      Comment

      • fusionx
        Confirmed User
        • Nov 2003
        • 4618

        #4
        bumpin' it back..

        Comment

        • Series
          Confirmed User
          • Jul 2004
          • 946

          #5
          a 'good stuff' bump ;)

          Comment

          • Coyote
            Drinker of Scotch
            • May 2003
            • 236

            #6
            bump^

            Nice info, thanks.
            Ethernet Servers

            Quote:
            CS: Linux can pretty much run on a potato. Which is a GOOD thing.

            Comment

            • nico-t
              emperor of my world
              • Aug 2004
              • 29901

              #7
              bumpin

              Comment

              • nico-t
                emperor of my world
                • Aug 2004
                • 29901

                #8
                ok i read it all, very useful info im gonna try some shit... + another bump for this thread!

                Comment

                • Diligent
                  Confirmed User
                  • Aug 2003
                  • 1594

                  #9
                  Always useful.
                  Thanks fusionx,

                  BUMP!
                  ~¤~ MORE MONEY ~¤~ VOD? XoD! ~¤~
                  ~¤~ ICQ# 9828 2461 ~¤~

                  Comment

                  • nico-t
                    emperor of my world
                    • Aug 2004
                    • 29901

                    #10
                    hm i need some help with this... i tried the hotlink code and it works, but if i wanna put a substitute image in place where normall the red x boxes appear, it doesnt work. I still see the red x's...
                    I looked on the web for answers but they all give the same code so the code is fine... do i have to put my own domein also in the list of sites that can hotlink? plus i tested it on a subdomain of me, does that require other code? because i also put that url in the accept hotlink list and still it doesnt work.

                    Comment

                    • Buzz
                      Confirmed User
                      • Apr 2004
                      • 1908

                      #11
                      really usefull thread
                      worth being bumped

                      Comment

                      • BBWTori
                        Confirmed User
                        • Oct 2003
                        • 615

                        #12
                        Just for shits and giggles....
                        BUMP!
                        Tori's Lair- Where Hot Fat Sex Reigns Supreme

                        ICQ # 18495959

                        Comment

                        • thonglife
                          So Fucking Banned
                          • Oct 2004
                          • 1566

                          #13
                          Originally posted by fusionx
                          RewriteEngine on
                          RewriteCond %{HTTP_REFERER} .*fusker*.*$ [NC]
                          RewriteCond %{HTTP_REFERER} .*usefulidiot*.*$ [NC]
                          RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ - [F,NC]
                          For some reason, that method of banning hot-linking never worked on my server. Here's another way if someone else has a similar problem. This does the same thing except this bans ALL hot-linking no matter who it is.

                          SetEnvIfNoCase Referer "^http://www.your-website.com/" locally_linked=1
                          SetEnvIfNoCase Referer "^http://www.your-website.com$" locally_linked=1
                          SetEnvIfNoCase Referer "^http://your-website.com/" locally_linked=1
                          SetEnvIfNoCase Referer "^http://your-website.com$" locally_linked=1
                          SetEnvIfNoCase Referer "^$" locally_linked=1
                          <FilesMatch "\.(gif|png|jpg)$">
                          Order Allow,Deny
                          Allow from env=locally_linked
                          </FilesMatch>

                          Comment

                          • bighitter
                            Confirmed User
                            • Oct 2003
                            • 126

                            #14
                            please help

                            I have an issue with .htaccess file that allows site access by referring url working with a site built in frames.

                            Certain mac users and misc. browsers simply won't get into the site with the frames, but there must be something.\
                            Big Hitters, Inc. - http://www.bighitters.com
                            Adult Prepaid - http://www.adultprepaid.com
                            icq: 136-923-236

                            Comment

                            • fusionx
                              Confirmed User
                              • Nov 2003
                              • 4618

                              #15
                              Originally posted by bighitter
                              I have an issue with .htaccess file that allows site access by referring url working with a site built in frames.

                              Certain mac users and misc. browsers simply won't get into the site with the frames, but there must be something.\
                              Do you mean they can't hit the site at all, can't navigate between frames or what? What do they see when they hit your root domain?

                              Comment

                              • fusionx
                                Confirmed User
                                • Nov 2003
                                • 4618

                                #16
                                Originally posted by nico-t
                                hm i need some help with this... i tried the hotlink code and it works, but if i wanna put a substitute image in place where normall the red x boxes appear, it doesnt work. I still see the red x's...
                                I looked on the web for answers but they all give the same code so the code is fine... do i have to put my own domein also in the list of sites that can hotlink? plus i tested it on a subdomain of me, does that require other code? because i also put that url in the accept hotlink list and still it doesnt work.
                                In the Rewriterule I used, there's a potential error. I say "potential" because it seems to still work on some servers.

                                Try this:

                                RewriteEngine on
                                RewriteCond %{HTTP_REFERER} .*somedomain.com*.*$ [NC]
                                RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://www.primanudes.com/hotlink/*******.jpg [R]

                                [the last line should not be broken]

                                the only real difference here is using the "[R]" in the RewriteRule line (instead of the [F,NC], which is wrong for a number of reason). Looks like some servers need to be explicitly told to redirect. It's probably a difference in the apache configs. If I get some time I'll look into that.

                                Comment

                                • nico-t
                                  emperor of my world
                                  • Aug 2004
                                  • 29901

                                  #17
                                  i got it why the image didnt work: the location of the image must be 'image/blabla.jpg' without the http://www.... in front of it. I dont know why, but anyway its working now.
                                  I also added some SE's names and i put it in a way that the SE's subdomains (like images.google.com) and every possible extension (like google.com, google.de etc. ) are both possible.
                                  Here is the code that works for me:

                                  RewriteEngine On
                                  RewriteCond %{HTTP_REFERER} !^$
                                  RewriteCond %{HTTP_REFERER} !^http://(www\.)?MYDOMAIN\.com/ [NC]
                                  RewriteCond %{HTTP_REFERER} !^http://(www\.)?gofuckyourself\.com/ [NC]
                                  RewriteCond %{HTTP_REFERER} !^http://(www\.)?gfy\.com/ [NC]
                                  RewriteCond %{HTTP_REFERER} !^http://(www\.)?cockboard\.com/ [NC]
                                  RewriteCond %{HTTP_REFERER} !^http://(www\.)?catyxxx\.com/ [NC]
                                  RewriteCond %{HTTP_REFERER} !^.*adultwebmasterinfo\.com/ [NC]
                                  RewriteCond %{HTTP_REFERER} !^.*msn\. [NC]
                                  RewriteCond %{HTTP_REFERER} !^.*yahoo\. [NC]
                                  RewriteCond %{HTTP_REFERER} !^.*altavista\. [NC]
                                  RewriteCond %{HTTP_REFERER} !^.*google\. [NC]
                                  RewriteCond %{HTTP_REFERER} !^.*webcrawler\. [NC]
                                  RewriteCond %{HTTP_REFERER} !^.*hoehoehoe\.net/ [NC]
                                  RewriteRule \.(jpe?g|gif|bmp|png)$ des/test/hotlinkimg-d.gif [L]

                                  Comment

                                  • Triple 6
                                    Confirmed User
                                    • Feb 2002
                                    • 5394

                                    #18
                                    bump


                                    good shit, ty
                                    SIG TOO SMALL! Maximum 1200x600 button and no more than 30 text lines of ALL SIZES and COLORS. Unless your sig is for a GFY top banner sponsor, then you may use a 6240x4800 instead of a 1024x800.

                                    Comment

                                    • jayeff
                                      Confirmed User
                                      • May 2001
                                      • 2944

                                      #19
                                      I believe there is an error in the "complete .htaccess file", in the line ending: [R=permanent,L]. My understanding is that the "L" means "last" and informs your server that this is the last rewrite command it will encounter. It is important that is only used for the last such command, because subsequent commands will be ignored.

                                      As a matter of form, there is no need to have the line "RewriteEngine On" more than once and it is more efficient (in terms of server use at least) to block access to images from within the directory/ies where they are stored, rather than from the root directory.

                                      Comment

                                      • Violetta
                                        Affiliate
                                        • Jul 2004
                                        • 28735

                                        #20
                                        very well written. Must have taken you hours!!!
                                        U never sleep do you J-man?

                                        Lars
                                        M&A Queen

                                        Comment

                                        • micke
                                          Confirmed User
                                          • Jul 2004
                                          • 497

                                          #21
                                          Great stuff!!

                                          Comment

                                          • kkikki
                                            Registered User
                                            • Feb 2005
                                            • 60

                                            #22
                                            i cant make it work on a mgp gallery, for a wmv file
                                            i tested to download the wmv file from other domain, it is still downloadable

                                            Comment

                                            • PureCute
                                              Registered User
                                              • Oct 2004
                                              • 39

                                              #23
                                              very good quality

                                              Bump because I was looking for something just like this!

                                              I will have to try out some of the info here... it should be useful

                                              Thanks

                                              Jim
                                              28259363

                                              Comment

                                              • fusionx
                                                Confirmed User
                                                • Nov 2003
                                                • 4618

                                                #24
                                                Originally posted by jayeff
                                                I believe there is an error in the "complete .htaccess file", in the line ending: [R=permanent,L]. My understanding is that the "L" means "last" and informs your server that this is the last rewrite command it will encounter. It is important that is only used for the last such command, because subsequent commands will be ignored.

                                                As a matter of form, there is no need to have the line "RewriteEngine On" more than once and it is more efficient (in terms of server use at least) to block access to images from within the directory/ies where they are stored, rather than from the root directory.
                                                Options +FollowSymLinks
                                                RewriteEngine on
                                                RewriteCond %{HTTP_HOST} !^www\.primanudes\.com
                                                RewriteRule (.*) http://www.primanudes.com/$1 [R=permanent,L]

                                                This actually informs the server that this is the last rewrite it will encounter for that particular set of conditions. The other blocks of rewrites are still handled correctly, because I explicitly say "RewriteEngine On" for each block of conditions. It also makes the code more readable, and the overhead is minimal. Now, if you have a very high traffic site and are nearing your delivery limits, you can certainly consolidate the various sections and get a few more connections out of the server.

                                                The efficiency is a trade off. I wanted to block all images from being accessed throughout the site, then open a couple of specific directories. Now, I could have added an .htaccess to each directory to block access, then left the others open, or, added another .htaccess to those directories that would allow hotlinking. Since I have many many subdirectories throughout my site, and the server has plenty of horsepower to handle the small amount of overhead, I decided to make life easier on myself. I only have to maintain two or three .htaccess files.

                                                Comment

                                                • fusionx
                                                  Confirmed User
                                                  • Nov 2003
                                                  • 4618

                                                  #25
                                                  Originally posted by kkikki
                                                  i cant make it work on a mgp gallery, for a wmv file
                                                  i tested to download the wmv file from other domain, it is still downloadable
                                                  Are you linking directly to the .wmv file. as in http://www.somedomain.com/dir/mymovie.wmv?

                                                  Comment

                                                  • fusionx
                                                    Confirmed User
                                                    • Nov 2003
                                                    • 4618

                                                    #26
                                                    Originally posted by PureCute
                                                    Bump because I was looking for something just like this!

                                                    I will have to try out some of the info here... it should be useful

                                                    Thanks

                                                    Jim
                                                    28259363
                                                    Thanks! Be sure to read through the various comments and posts - there were some errors

                                                    Comment

                                                    • fusionx
                                                      Confirmed User
                                                      • Nov 2003
                                                      • 4618

                                                      #27
                                                      Originally posted by Rockatansky
                                                      very well written. Must have taken you hours!!!
                                                      U never sleep do you J-man?

                                                      Lars
                                                      Sleep is highly overrated

                                                      Comment

                                                      • sinnerscorner
                                                        Confirmed User
                                                        • Jul 2004
                                                        • 194

                                                        #28
                                                        I like to know is it possible assuming you trap those
                                                        nasty fusker hotlinking cheaters with an .htaccess
                                                        to redirect them to a picture on their own site?
                                                        -- ok there is no sig here --

                                                        Comment

                                                        • nmcog
                                                          Confirmed User
                                                          • Sep 2004
                                                          • 825

                                                          #29
                                                          Originally posted by sinnerscorner
                                                          I like to know is it possible assuming you trap those
                                                          nasty fusker hotlinking cheaters with an .htaccess
                                                          to redirect them to a picture on their own site?
                                                          Yes...
                                                          http://www.htaccesstools.com/hotlink-protection/
                                                          'Blocked Image URL'

                                                          But it'll be useless, since the images would have already been cached in the surfers browser.

                                                          Comment

                                                          • cachondo
                                                            Confirmed User
                                                            • Sep 2004
                                                            • 808

                                                            #30
                                                            Great job.


                                                            With .htaccess you can too put *.php files in *.html
                                                            medianetpay.com

                                                            Comment

                                                            • syntacks
                                                              Confirmed User
                                                              • Dec 2004
                                                              • 147

                                                              #31
                                                              thanx for the info fusionx!
                                                              Try Loaded Get Lust

                                                              Comment

                                                              • EddiePulp
                                                                Confirmed User
                                                                • Mar 2004
                                                                • 1332

                                                                #32
                                                                so how can i make a htaccess file that will let all subdomains
                                                                ie. sub1.domain.com sub2.domain.com www.domain.com sub3.domain.com all link off each other without adding the word sub1, sub2 sub3 to the htaccess file?
                                                                ie. can you just go *.domain.com ?
                                                                I dont need a sig.

                                                                Comment

                                                                • fusionx
                                                                  Confirmed User
                                                                  • Nov 2003
                                                                  • 4618

                                                                  #33
                                                                  Originally posted by EddiePulp
                                                                  so how can i make a htaccess file that will let all subdomains
                                                                  ie. sub1.domain.com sub2.domain.com www.domain.com sub3.domain.com all link off each other without adding the word sub1, sub2 sub3 to the htaccess file?
                                                                  ie. can you just go *.domain.com ?
                                                                  Yes

                                                                  RewriteCond %{HTTP_REFERER} .*somedomain.com*.*$ [NC]

                                                                  should cover any subdomain, or actually, any referrer string with "somedomain.com" anywhere in it.

                                                                  Comment

                                                                  • Yahook
                                                                    Confirmed User
                                                                    • May 2002
                                                                    • 840

                                                                    #34
                                                                    Good article, thanks Fusion!

                                                                    Comment

                                                                    • badboyyy1974
                                                                      Confirmed User
                                                                      • May 2005
                                                                      • 108

                                                                      #35
                                                                      bump = thanks for tute
                                                                      Announcing: NewPaysites - Promote the newest, freshest paysites.

                                                                      Comment

                                                                      • mikah9
                                                                        Confirmed User
                                                                        • Feb 2004
                                                                        • 290

                                                                        #36
                                                                        bump.
                                                                        nice one fusion.

                                                                        Comment

                                                                        • kernelpanic
                                                                          Too lazy to set a custom title
                                                                          • Jan 2005
                                                                          • 2961

                                                                          #37
                                                                          This is a quality tutorial, and a must read for anyone managing their own site. With all the hotlinking and other forms of bandwidth theft rampant across the internet, this knowledge is practically essential.

                                                                          Heres a bump.


                                                                          ZangoCash - Turn Your Traffic Into Ca$h.
                                                                          $.40 Per Install - No Tier

                                                                          Comment

                                                                          • runningbuffalo
                                                                            Confirmed User
                                                                            • Jun 2004
                                                                            • 161

                                                                            #38
                                                                            thanks for the information

                                                                            very helpful...thanks
                                                                            Jesse

                                                                            All content comes with 2257 documents
                                                                            [email protected] ICQ:239337547

                                                                            Comment

                                                                            • fusionx
                                                                              Confirmed User
                                                                              • Nov 2003
                                                                              • 4618

                                                                              #39
                                                                              Originally posted by kernelpanic
                                                                              This is a quality tutorial, and a must read for anyone managing their own site. With all the hotlinking and other forms of bandwidth theft rampant across the internet, this knowledge is practically essential.

                                                                              Heres a bump.
                                                                              Yep - it's necessary info.

                                                                              Some hosts won't lift a finger to help, so you gotta know it, or have access to a reference. Besides, it's fun spamming your logo on hotlinking sites

                                                                              Comment

                                                                              • fusionx
                                                                                Confirmed User
                                                                                • Nov 2003
                                                                                • 4618

                                                                                #40
                                                                                Originally posted by runningbuffalo
                                                                                very helpful...thanks
                                                                                Welcome

                                                                                Comment

                                                                                • sniperwolf
                                                                                  Too lazy to set a custom title
                                                                                  • Mar 2005
                                                                                  • 17743

                                                                                  #41
                                                                                  very cool.. interesting facts you got there
                                                                                  ~Accepting design works~

                                                                                  Comment

                                                                                  • gunfodder
                                                                                    Confirmed User
                                                                                    • Aug 2004
                                                                                    • 245

                                                                                    #42
                                                                                    just doing the bump as it is usefull stuff
                                                                                    Everybody together now, repeat after me ... We are all individuals.

                                                                                    Comment

                                                                                    • apscripts
                                                                                      Confirmed User
                                                                                      • Mar 2003
                                                                                      • 204

                                                                                      #43
                                                                                      Most people don't know that you can read cookies using mod_rewrite in .htaccess as well. I've seen people selling web applications to protect video files from hotlinking for hundreds of dollars when all you need to do is this...

                                                                                      http://www.gfy.com/showpost.php?p=1543253&postcount=3

                                                                                      I posted that years ago

                                                                                      Note: upon reading this I am not sure why I didn't mention using plain ol' j a v a s c r i p t to set the cookie on your video thumbnail document...
                                                                                      Last edited by apscripts; 06-23-2005, 09:40 PM.
                                                                                      icq5708193

                                                                                      aptgp III -- Build a Blog, an RSS feed, a text TGP, and a thumb TGP all from one installation. Own Comus or AutoGallery? Have APTGP III Installed free for 30 days; no obligations.

                                                                                      Comment

                                                                                      • kaori
                                                                                        Confirmed User
                                                                                        • Apr 2005
                                                                                        • 1569

                                                                                        #44
                                                                                        Good stuff.. I just got fuskered for 14gb a day
                                                                                        good thing I check my logs every 2 days...
                                                                                        let's see if this'll get 'em.. 4 of 'em on the same day.. blech
                                                                                        fusker.lewww.com
                                                                                        fusker.org
                                                                                        fusker.com
                                                                                        and fusker.wegotcandy.com

                                                                                        Comment

                                                                                        • apscripts
                                                                                          Confirmed User
                                                                                          • Mar 2003
                                                                                          • 204

                                                                                          #45
                                                                                          I should also note that my setcookie() example was incorrect.

                                                                                          1) In PHP, your videogallery.php would have the first line:

                                                                                          setcookie("auth", "yes", 0, "/", ".mydomain.com");

                                                                                          2) In the /videos dir where all your mpgs are (to which the thumbnails on videogallery.php link), you would have a .htaccess with this:

                                                                                          RewriteEngine On
                                                                                          RewriteOptions inherit
                                                                                          RewriteCond %{HTTP_COOKIE} !(^|(.+;)*)auth=yes(;.*|$)
                                                                                          RewriteRule /* http://www.mydomain.com/hotlink/drm.wmv [R,L]

                                                                                          So the dir structure is this:

                                                                                          /videogallery.php
                                                                                          /videos/.htaccess
                                                                                          /videos/some.mpg
                                                                                          /videos/some2.mpg
                                                                                          /videos/some.mov
                                                                                          /videos/some.avi

                                                                                          Hopefully that makes more sense.
                                                                                          icq5708193

                                                                                          aptgp III -- Build a Blog, an RSS feed, a text TGP, and a thumb TGP all from one installation. Own Comus or AutoGallery? Have APTGP III Installed free for 30 days; no obligations.

                                                                                          Comment

                                                                                          • seoguy
                                                                                            Confirmed User
                                                                                            • Nov 2004
                                                                                            • 381

                                                                                            #46
                                                                                            hi,

                                                                                            i have this here right now:

                                                                                            RewriteEngine on
                                                                                            RewriteCond %{HTTP_REFERER} .*.fusker* [NC,OR]
                                                                                            RewriteCond %{HTTP_REFERER} .*.whatboyswant* [NC,OR]
                                                                                            RewriteCond %{HTTP_REFERER} .*.beyond8* [NC,OR]
                                                                                            RewriteCond %{HTTP_REFERER} .*.av999* [NC]
                                                                                            RewriteRule ^.+\.(jpg|jpeg|png|gif)$ - [NC,F,L]

                                                                                            ErrorDocument 404 http://www.mysite.com/404.htm
                                                                                            ErrorDocument 403 http://www.mysite.com/404.htm
                                                                                            ErrorDocument 500 http://www.mysite.com/404.htm


                                                                                            does this look ok?

                                                                                            could i also write

                                                                                            RewriteCond %{HTTP_REFERER} .*.fusker.org* [NC,OR]

                                                                                            instead of

                                                                                            RewriteCond %{HTTP_REFERER} .*.fusker* [NC,OR]

                                                                                            ???

                                                                                            what about surfer using Norton Internet Security. I heared with the HTTP_REFERER they might be blocked...

                                                                                            HELP pls ?!?!?!

                                                                                            Comment

                                                                                            • sinnerscorner
                                                                                              Confirmed User
                                                                                              • Jul 2004
                                                                                              • 194

                                                                                              #47
                                                                                              Originally posted by seoguy
                                                                                              what about surfer using Norton Internet Security. I heared with the HTTP_REFERER they might be blocked...

                                                                                              HELP pls ?!?!?!

                                                                                              That might be true. I am not using it (I am using Kerio Firewall) but I know
                                                                                              norton sometimes blocks and only shows red crosses.

                                                                                              I am not sure when Norton does this (is it with default settings? installed)


                                                                                              Other firewalls might not display banners who are called banner or ads or etc.
                                                                                              I know mine (Kerio) blocks files called Banner or ad etc with default [advanced] settings......
                                                                                              -- ok there is no sig here --

                                                                                              Comment

                                                                                              • seoguy
                                                                                                Confirmed User
                                                                                                • Nov 2004
                                                                                                • 381

                                                                                                #48
                                                                                                Ok, so fusionx just helped me via ICQ and this is what my finished htaccess looks like now. I think every newbie could use the same and do the right thing:

                                                                                                Options All -Indexes

                                                                                                RewriteEngine on
                                                                                                RewriteCond %{HTTP_REFERER} .*.fusker* [NC,OR]
                                                                                                RewriteCond %{HTTP_REFERER} .*.whatboyswant* [NC,OR]
                                                                                                RewriteCond %{HTTP_REFERER} .*.beyond8* [NC,OR]
                                                                                                RewriteCond %{HTTP_REFERER} .*.av999* [NC]
                                                                                                RewriteRule ^.\.(jpg|jpeg|png|gif)$ - [NC,F]

                                                                                                ErrorDocument 400 http://www.yourdomain.com/404.html
                                                                                                ErrorDocument 403 http://www.yourdomain.com/404.html
                                                                                                ErrorDocument 404 http://www.yourdomain.com/404.html
                                                                                                ErrorDocument 500 http://www.yourdomain.com/404.html
                                                                                                ErrorDocument 501 http://www.yourdomain.com/404.html
                                                                                                ErrorDocument 503 http://www.yourdomain.com/404.html


                                                                                                He also told me that there are only a few users i might loose because of norton :-)

                                                                                                Thanks again ;-)

                                                                                                Comment

                                                                                                • fusionx
                                                                                                  Confirmed User
                                                                                                  • Nov 2003
                                                                                                  • 4618

                                                                                                  #49
                                                                                                  Actually, doing it that way, you will lose NO users. However, a few users will be able to see your images on a fusker site - not enough to worry about.

                                                                                                  The reason is, you are dropping requests from matched referers. If there is no referer, there is no match, so the request is not dropped.

                                                                                                  Comment

                                                                                                  • seoguy
                                                                                                    Confirmed User
                                                                                                    • Nov 2004
                                                                                                    • 381

                                                                                                    #50
                                                                                                    sorry, small correction:

                                                                                                    it has to be

                                                                                                    RewriteRule ^.*\.(jpg|jpeg|png|gif)$ - [NC,F]

                                                                                                    ;-)

                                                                                                    Comment

                                                                                                    Working...