PDA

View Full Version : .htaccess question


PhunkyMonkey
08-24-2006, 01:56 PM
I've been reading up on how to stop hotlinking from a specific site
(myspace is the devil), but there is something I am not sure of...

Where do I ender the code in my .htaccess file?
Do I replace the whole file with the code, or enter it between the lines? Currently the file looks like this ~


### CNC_START: BEGIN CUSTOM WEBSITE CONFIGURATION
### DO NOT EDIT THIS SECTION, CHANGES WILL BE LOST
Options +Indexes
php_value error_reporting 7
php_flag display_errors off
### CNC_END: END CUSTOM WEBSITE CONFIGURATION



The code I was planning on adding is from this site ~
http://altlab.com/htaccess_tutorial.html
Which should display a 403 Forbidden error code instead of an image.


RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]



So, where does this code go?
Also, if you know if any problems with the code, please let me know of a better one.
I know there are a lot of them on the forums, but they all seemed to use an image.
Any help is appreciated ;)

PaulKroll
08-24-2006, 02:45 PM
Notice that "Do Not Edit This Section, Changes Will Be Lost" instruction? So put the extra code, after the "End Custom..." line. :)

Andilinks
08-24-2006, 03:23 PM
I've found the server to be very unforgiving of errors in the .htaccess file so it is wise to check everything after making changes.

Once you turn the "Rewrite Engine On" you can add many operations under it.

This is the code I use to block all referrals from baddomain.com, it works fine.

RewriteEngine on
RewriteCond %{HTTP_REFERER} baddomain\.com [NC]
RewriteRule .* - [F]


If you don't get any actual business from myspace blocking *all* referrals may keep some bw poachers from finding you in the first place and will block graphics transfers too.

But, if you get sales referrals from myspace too that makes it a bit trickier and just blocking images will only help with bw usage and may kill some sales. Just one sale may pay for a lot of bandwidth...
If they like your pictures they may want to buy your clothes too, if only you can reach them.

Maybe you could make your stolen graphics into ads for your products by adding your url on them, then it is free advertising.

kitchin
08-24-2006, 03:28 PM
If you make the last line of your .htaccess file just this:
#
then that will prevent a little error that can happen with missing the last line ending.

Also, make sure to upload it as ascii/text. You can call it htaccess.txt and then change the name after you upload it.

PhunkyMonkey
08-25-2006, 09:13 AM
Thank you so much!

I was thinking it would go between the DO NOT EDIT and the END CUSTOM line ~ this is why I asked!

I changed the code, and checked a few pages on my site. Do I need to go through *every* page? I checked myspace and I don't see any of my pictures... I can't wait to see my statistics page next month. Ahhh :)

Do I need to have my site checked on other browsers?



No, I do not get any sales from myspace, just people using my images for their backgrounds or decorations. I would slap the url on there, but most of them are very young and I don't think they would be buying anything.

I do occasionally have people post an item in their blog (usually with a link to my site) to tell their friends about it, so I didn't want to disable right clicking or block everyone.

Andilinks
08-25-2006, 10:00 AM
Do I need to go through *every* page? I suppose it may be different if you inserted code that for some reason affected just certain pages or certain browsers, but errors I have found killed the entire site and returned a "500 server error" for everything... So I just check one page, or one page that has images if I used code that affected images, etc.

If you are blocking referrers you have to check your logs to see if the code is working (403) for that referrer.

Andi