cgmsys
11-13-2004, 06:34 PM
I've been noticing some hotlinking to pics on my site, mostly from totally unrelated forums.
I tried creating an .htaccess file. When I put that in the root it blocked the hotlinks but my site was getting a server 500 error. WH renamed the .htaccess and I could get into everything
they suggested that I try the .htacces in one folder until it was working right. It seemed to work once but it is not working now(i.e. not blocking hotlinking.) I tried a number of versions such as
Rewriteengine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://bucksviews.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.bucksviews.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://206.130.100.218/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG)$ - [F]
I read that .htaccess can slow things down when it is in the root since every file read has to check with .htaccess. I then looked into httpd.conf. I'm a bit fuzzy on the exact code to put in there.
I didn't want to make major changes to httpd.conf. What I did was
1. Put the code you see above in access.conf.
2. Remove the # from the line in httpd.conf that references the access.conf file (I think that will 'unremark' the line to allow apache to see access.conf. let me know if I am wrong.
3. Went into the westhost control panel and restarted vps. From what I read the httpd.conf gets read at startup. Am I correct in assuming that this restarts the virtual server?
Other questions:
1. Does anyone have a sample of code to go into httpd.conf or access.conf to stop hotlinking?
2. I understand that you want to only block referrers other than your site and you want to allow blank referrers (i.e google.) Does anyone know if an httpd.conf file blocking will do this?
3. Where in the httpd.conf file do you put the anti hotlinking code?
Thanks
I've been working on this for a couple of hours and I am at my wit's end.
I'd appreciate any thoughts or advice.
chris
I tried creating an .htaccess file. When I put that in the root it blocked the hotlinks but my site was getting a server 500 error. WH renamed the .htaccess and I could get into everything
they suggested that I try the .htacces in one folder until it was working right. It seemed to work once but it is not working now(i.e. not blocking hotlinking.) I tried a number of versions such as
Rewriteengine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://bucksviews.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.bucksviews.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://206.130.100.218/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG)$ - [F]
I read that .htaccess can slow things down when it is in the root since every file read has to check with .htaccess. I then looked into httpd.conf. I'm a bit fuzzy on the exact code to put in there.
I didn't want to make major changes to httpd.conf. What I did was
1. Put the code you see above in access.conf.
2. Remove the # from the line in httpd.conf that references the access.conf file (I think that will 'unremark' the line to allow apache to see access.conf. let me know if I am wrong.
3. Went into the westhost control panel and restarted vps. From what I read the httpd.conf gets read at startup. Am I correct in assuming that this restarts the virtual server?
Other questions:
1. Does anyone have a sample of code to go into httpd.conf or access.conf to stop hotlinking?
2. I understand that you want to only block referrers other than your site and you want to allow blank referrers (i.e google.) Does anyone know if an httpd.conf file blocking will do this?
3. Where in the httpd.conf file do you put the anti hotlinking code?
Thanks
I've been working on this for a couple of hours and I am at my wit's end.
I'd appreciate any thoughts or advice.
chris