Hi,
I just moved a site from Mambo to Drupal. It's been working great in a subdomain for testing, however once I moved it to the main place the server went down due to the number of page requests!
After looking at the logs I found the problem. Many people and sites were/are hotlinking some of the images hosted in my server, the problem is that those images are no longer available, so the url rewriting defined in Drupal's .htaccess routes them to index.php. The result is that everytime I enable the .htaccess, after a couple of minuttes the server is unresponsive :(
I'm trying to play with the rewriting rules to make it skip the image files but I'm not very good with mod_rewrite.
Perhaps it'll be a good idea to modify the supplied .htaccess file to handle this issue or at least, mentioning them in the install text.
ivan
Comments
Stop Hotlinking
This should work for you.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?YOURDOMAIN.com(/)?.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png|swl|avi|mpg)$ http://YOURDOMAIN.com/PAGE_TO_REDIRECT [R,NC]
Hope it works for you.
Thanks Ontime, I'm using a
Thanks Ontime, I'm using a very similar rule.
I don't know why though, when using it in conjunction with the default Drupal rules for clean urls it doesn't work :(
I just disabled clean urls and the rewrite rules for it.
Stop file leech / hot link of image files...
OMGosh how did you ever get so many people using your bandwidth? Sounds like a couple of people don't like you lol. Hopefully they haven't made you run too high on bandwidth.
As for clean urls and leech burning, try this ... works fine with clean urls for me. Put it AFTER the url stuff.
#
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://yursite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://yursite.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://yursite.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://yursite.net$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yursite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yursite.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yursite.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yursite.net$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.yursite.com [R,NC]
#
(lessthan)Files 403.shtml>
order allow,deny
allow from all
(lessthan)/Files>
#
Replace lessthan with lessthan symbol. Drupal dropped the code so I put it in like that so you could see it.
Try to link to a file on http://drupal.cyberocity.com/ ... should be a broken link.
---------------
LeBlank
To try to avoid
To try to avoid problems with the drupal htaccess I created an htaccess and placed it in the directories where the images are stored.
Will try leblank's postioning of it and see what happens.
Leblank - I tried this http://drupal.cyberocity.com/bluesmoke_logo.png and the image can be served from my site. Tried other links too and all pages I linked to are served without error.
Must still have a problem with your htaccess somewhere. :O
Thanks :)
LOL from on my site I can't see them without the htaccess set like that lol ... I'll try a few links from another page. Thanks.
---------------
LeBlank
Location, Location, Location
Location, Location, Location LOL
I've always placed htaccess in all directories I don't want hotlinked and have success.
Hope you get it working right as I'm sure you will.
ACK! You had that file in your cache already lol :)
Try one not in your cache and put it in a link ... try this line complete in an html file ...
Here is the image! ->(start tag) img src="http://drupal.cyberocity.com/files/c500.png" alt="nannynannyboobooo" (end tag)
or go to http://cyberocity.com/linktest.html where it is set up already. If you have ever been to the site and looked at that file anytime before it will show from your cache not the site.
---------------
LeBlank
ROFLMAO
ROFLMAO - oops and AACK!
Sorry, so I slipped up. LOL
You are correct. The nannynanny..... is locked and your htaccess is working.
BLUSHING ever SO slightly...
.htaccess and (better) alternatives
Using .htaccess can put a hit on performance. Anyone with root access on their servers might want to look at this, if they haven't already:
http://httpd.apache.org/docs-2.0/howto/htaccess.html#when
--
mediagirl.org
yes I am stuck with htaccess ...
... files. On my win dev machine I get to play with my apache directories in the httpd.conf file, specially cause windows doesn't use htaccess files. I don't know what the directory settings would look like to stop file leeching in the .conf file though.
---------------
LeBlank
I am using DOMAIN ACCESS
I am using DOMAIN ACCESS which sets up aliases / multiple domains
How would I extend the 1st line of the .htaccess code below to allow all my other domains?
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?cdman\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpx [L]