Need Help With .htacess To Tighten Up Security!

Discussion in 'Programming' started by jvfconsulting, Jan 10, 2008.

  1. #1
    I'm trying to tighten up security here. Right now access to my folders can be seen by anyone. What I would like to do is redirect any traffic that tries to hit these pages to my homepage jvfconsulting.com

    this is the url to the folder I would like to restrict access to.
    http://www.jvfconsulting.com/amass/images/

    This code worked and it would redirect you to the url if you clicked on the picture, but all the pics on the website would not work.
    RewriteEngine on
    RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://www.jvfconsulting.com [R,NC]

    This one would work only if you were in one directory…
    redirect 301 /amass http://www.jvfconsulting.com/
     
    jvfconsulting, Jan 10, 2008 IP
  2. nasty.web

    nasty.web Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just add "Options -Indexes" to your .htaccess to disable directory listing.
     
    nasty.web, Jan 10, 2008 IP
  3. chrissyj

    chrissyj Peon

    Messages:
    56
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello all! Yes, but the above code does not stop people from LINKING to your images! (Like from another website. It does stop people from getting a DIRECTORY of your images.) However, the following code DOES block all external references, but not references from the website:

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://www\.yoursitenamehere\.com/.*$ [NC]
    RewriteRule \.(gif|jpg|png)$ - [F]

    It returns an HTTP FAIL code.

    There is a way to do what jvfconsulting asked about (send any invalid reference to the home page), but that is a bit more involved.

    Enjoy!
     
    chrissyj, Jan 10, 2008 IP
  4. jmf000

    jmf000 Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The following should work
    
    RewriteRule ^/amass/(.*)$ http://www.jvfconsulting.com [R]
    
    Code (markup):
    Or even better place the following in .htaccess file in amass directory
    
    RewriteEngine On
    RewriteRule ^.*$ http://www.jvfconsulting.com [R]
    
    Code (markup):
     
    jmf000, Jan 10, 2008 IP
  5. jvfconsulting

    jvfconsulting Active Member

    Messages:
    1,089
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    90
    #5
    Thanks Nasty.Web & chrissyj! I ended up using a code that just blocks access to all the files. I'm going to give the code jmf000 just posted about and see if that works for me. Here is the code that i'm using in the mean time. Is this incorrect and if so why?
    The .htacess file was placed in my public_html folder with only 1 line of code and this was it...

    Options -Indexes
     
    jvfconsulting, Jan 11, 2008 IP