Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Can someone simplify my .htaccess please

    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?


    Code:
     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]

  • #2
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    In order to make sure each site I want can hotlink from me, I have these lines for each site:

    Code:
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •