Quick basic question, please help

Discussion in 'PHP' started by Johnny503, Aug 9, 2008.

  1. #1
    My question:

    Is there any code that can put in .htaccess or something in root public_html .. whenever a dir (folder) without having index.html in there. But when people type i.e. www.test.com/test/ (they will not see the files in there, since usually they could see the files listed out on their browser due to no index.html or index.php)

    So, I want whenever they enter to the dir without index file, it will re-direct them back to main homepage . Is this possible to do ? I saw once before.

    Thanks for trying to help out
     
    Johnny503, Aug 9, 2008 IP
  2. XT Gohan

    XT Gohan Greenhorn

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    What you are looking for is called mod_rewrite. Unfortunately, I don't think many of the people here are skilled with that kind of stuff, they do have a section for it but it may or may not apply to you. You can use these forums:

    http://forum.modrewrite.com/
    Code (markup):
    They usually respond within a few days if not sooner.
     
    XT Gohan, Aug 9, 2008 IP
  3. infinivert

    infinivert Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Mod_rewrite is the best solution if you don't want to have real directories. However, if you want to have real directories, I don't think that's the direction you want to go. A simple .htaccess redirect is easy enough to make if you have a set number of directories to protect.
    Redirect 301 "/directory/to/protect/" /index.html
    Code (markup):
    --Josh
     
    infinivert, Aug 9, 2008 IP
  4. Trusted Writer

    Trusted Writer Banned

    Messages:
    1,370
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    160
    #4
    You can also make a 404 error page redirecting to the main page, but the drawback is the risk of search engines penalties.

    Another thing that you can put in your .htacces files to avoid get your files displayed, whether redirection takes place or not, is adding this line at the very top:
    IndexIgnore *
    Code (markup):
    This simple line prevents people can see any file inside any directory if there is no index file or redirection available.
     
    Trusted Writer, Aug 9, 2008 IP
  5. Johnny503

    Johnny503 Active Member

    Messages:
    578
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #5
    Thanks guy
     
    Johnny503, Aug 10, 2008 IP