I need help creating .htaccess file for my website

Discussion in 'Programming' started by Krakatao, Nov 7, 2013.

  1. #1
    As my title is saying I want to create .htaccess which is hosted on subdomain. Website is very simple - 5 pages big, coded in HTML and CSS (no Wordpress or any other platform).

    What I need...

    1. Want to prevent people accessing my image or any other folder

    For example my website is: dogs.example.com and I don't want that people are able to go to dogs.example.com/images. Instead I want to block them when they type that kind of URL and redirect them to my hompage.

    2. Need lines to prevent image hotlinking too...

    3. How to make my website using gzip effectively

    I am using shared Hostgator plan so I am able to edit my .htaccess files.

    Thx in advance for any help!
     
    Krakatao, Nov 7, 2013 IP
  2. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    I would recommend just putting an index.html file in your images directory. And then adding a <meta> refresh tag or JavaScript document.location to redirect them to your home page. If all else fails they still won't be able to see your whole image directory.

    Unless you're running a fairly large site or got completely boned on bandwidth with the hosting plan you purchased (or got for free) I wouldn't worry about it. Not that many people are going to try to steal your images without downloading them for themselves and uploading them to their own server. However, if you're really worried about it, if I'm not mistaken HostGator has a function in the cPanel to disable hot linking images which works somewhat effectively if I remember correctly.

    I'm not really sure what the third question is asking
     
    Pudge1, Nov 7, 2013 IP
  3. vishals

    vishals Active Member

    Messages:
    208
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #3
    There is a directive called NoIndex in Apache .htaccess file, which will stop the server from showing any directory listing in your site. Maybe that will help you with point 1.
     
    vishals, Nov 13, 2013 IP
  4. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #4
    Don't worry so much about people accessing your images directly. If you don't want them to view the directory listing you can simply add a blank index.html file or like vishals suggested use htaccess. Don't worry about hot linking to your images.. that really was only a concern 10 years ago when web hosts only gave you 25 MB of space and 100 MB of bandwidth.
     
    NetStar, Nov 14, 2013 IP