.htaccess question, pulling up external list.txt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkx
    Confirmed User
    • Nov 2003
    • 4001

    #1

    .htaccess question, pulling up external list.txt

    Need to use the same list of IP's to block on a few of my sites. Can I make it go to a list.txt file on the server somehow?

    Current .htaccess:
    ##### start anti spy squirrel script
    deny from XX.XX.XX.X
    ErrorDocument 403 /error.html
    ##### end anti spy squirrel script

    want to:

    ##### start anti spy squirrel script
    deny from http://www.mysite.com/list.txt
    ErrorDocument 403 /error.html
    ##### end anti spy squirrel script

    and in list.txt i will list the ip's I want to block line by line.

    How do I properly say this line?
    deny from http://www.mysite.com/list.txt
  • anicetan
    Registered User
    • Mar 2003
    • 73

    #2
    I think you can do it with mod rewrite

    High Quality - Low Prices

    Comment

    • mkx
      Confirmed User
      • Nov 2003
      • 4001

      #3
      code perhaps?

      Comment

      • darksoul
        Confirmed User
        • Apr 2002
        • 4997

        #4
        you can't do that with .htaccess alone.
        1337 5y54|)m1n: 157717888
        BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
        Cambooth

        Comment

        • GrouchyAdmin
          Now choke yourself!
          • Apr 2006
          • 12085

          #5
          Originally posted by darksoul
          you can't do that with .htaccess alone.
          Why did you base64 encode your ICQ?

          Also, what's stated here.

          It'd be easier for you just to make a script which reads the list.txt and prepends it to your .htaccess

          This has no bounds checking and is dumb as hell, but will do what you want. Trivially wrapped as a CGI so you can activate via browser rather than shell. Again, it's stupid, but it's free.

          addnewbans.cgi:
          Code:
          #/bin/sh
          echo "Content-type: text/plain"
          echo ""
          echo "Parsing list.txt in current directory..."
          for n in `cat list.txt`; do echo "deny from $n" >> newshit
          cp .htacess .htaccess-last
          mv newshit .htaccess
          cat .htaccess-last >> .htaccess
          echo "Done. .htaccess has new bans set; last copy is saved as .htaccess-last"
          Edit: For denying a specific URL you'll want to use mod_rewrite.

          Code:
          RewriteCond %{HTTP_REFERER} ^http://clownpenis\.fart/booz.html [NC, OR]...
          RewriteRule ^.*$ - [F]
          Last edited by GrouchyAdmin; 02-03-2010, 07:22 PM. Reason: I only answered part of the question.

          Comment

          • mkx
            Confirmed User
            • Nov 2003
            • 4001

            #6
            Thanks dude will try that out

            Comment

            Working...