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
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.
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
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.