...

View Full Version : Can someone simplify my .htaccess please



Riboflavin
02-03-2011, 09:05 AM
This is my .htaccess I use for only allowing certain sites to hotlink files from my website. As you can see, it is pretty cluttered and I'm sure there is a better way to write this so it is shorter. As you can see I am kind of a noob at this and this is the only way I could make it work and block all sites except what I allow (including subdomains and https). Can anyone help me out? :thumbsup:



RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://site1.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site1.net$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site2.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site2.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site4.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site4.net$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site4.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site4.net$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site5.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site5.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site6.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site6.net$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site7.me/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site7.me$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site8.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site8.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site9.me/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site9.me$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site10.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site10.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site11.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site11.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://subdomain.site12.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://subdomain.site12.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site13.eu/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site13.eu$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site14.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site14.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://subdomain.site15.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://subdomain.site15.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site16.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site16.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site12.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site12.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site1.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site1.net$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site5.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site5.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site8.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site8.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site9.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site9.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site10.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site10.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site11.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site11.org$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site13.eu/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site13.eu$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site14.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site14.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site16.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site16.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site1.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site1.net$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site6.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site6.net$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site7.me/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site7.me$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site8.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site8.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site9.me/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site9.me$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site10.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site10.org$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site11.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site11.org$ [NC]
RewriteCond %{HTTP_REFERER} !^https://subdomain2.site12.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://subdomain2.site12.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://subdomain.site12.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://subdomain.site12.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site2.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site2.org$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site13.eu/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site13.eu$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site14.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site14.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site16.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site16.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site1.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site1.net$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site8.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site8.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site9.me/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site9.me$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site10.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site10.org$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site11.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site11.org$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site13.eu/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site13.eu$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site14.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site14.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://subdomain.site15.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://subdomain.site15.com$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site16.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site16.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://anonym.to/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://anonym.to$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|png|bmp|css|php)$ - [F,NC]

Riboflavin
02-07-2011, 01:46 AM
In order to make sure each site I want can hotlink from me, I have these lines for each site:


RewriteCond %{HTTP_REFERER} !^http://site1.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://site1.net$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site1.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.site1.net$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site1.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://site1.net$ [NC]

Is there a way to combine http and https and all possible subdomains into one line?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum