The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.htaccess help.???

Discussion in 'General Discussion' started by hostserve, Aug 28, 2007.

  1. hostserve

    hostserve Well-Known Member

    Joined:
    Aug 25, 2006
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    6
    Good afternoon Folks,

    I am having a small issue... I recently purchased a script that I want to be able to use, but the company that wrote the script did not include an "index" page for us to use, they included a "login.php" page in stead so every time I go to the directory that the script is in you can see all the files in the directory from the webpage.

    As we all know its a security concern and a real pain in the butt, I'd like to change the .htaccess file to include "login.php" as an optional page to load so that when I go to the directory it loads that page to make my life easy.

    What do I have to do to make this happen... I've never touched an .htaccess file before.
     
  2. niccell

    niccell Well-Known Member

    Joined:
    Aug 10, 2005
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    You don't have to monkey with an .htaccess file for this...there are several ways to redirect your file....

    1) Create an index.php (if the server supports PHP) and enter this code (changing the URL to where you want it to go):


    <?php
    header( 'Location: http://www.yoursite.com/new_page.html' ) ;
    ?>


    You can also do the same with an index.html page, using a redirect:

    _________________________________________________________________________________

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Your Page Title</title>
    <meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>
    <BODY>
    Optional page text here.
    </BODY>
    </HTML>
    _________________________________________________________________________________
     
  3. RMIGHTY1

    RMIGHTY1 Registered

    Joined:
    Jul 25, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    North of Chicago, Illinois USA
    Hiding files in a directory

    Hello Hostserve,

    No need to modify .htaccess if you don't want to. Simply navigate to the directory in question using the cPanel "Files" feature and add an "index.htm" file within that directory.

    To do so, while in the directory in question, click on "create a new file." In the right hand side of the window, type "index.htm" or "index.html" and from the drop down window, choose "HTML Document" type. This will create a blank html index file which will prevent the public web from seeing inside your directory. When that directory is entered into a browser, e.g., http://mydomain.com/private/ a blank white page will appear. If you wish to display a message, say so in the index.htm file created.

    To access your login script, be sure to include the complete address in the browser window, e.g., http://yourdomain.com/private/login.php

    Summary: 1. Add "index.htm" file to directory you wish to protect from displaying contained files.
    2. Use the complete path including your "login.php" filename in a browser to access it.

    The files in your directory will no longer be visible to the public web when they enter your directory name into their browser. Instead, they will only see your blank (or whatever) index.htm page within that directory. Much simpler than modifying .htaccess file (although that is relatively simple too).

    ******
    Entering the following in an .htaccess file within the directory in question will bring up your login.php file as the default file for that directory:

    DirectoryIndex login.php
    ******
    That in itself will not however prevent directory files from being displayed. Adding an index.htm file to the directory will prevent prying eyes from seeing the directory's file contents.

    Tip: I have used cPanel's index manager to accomplish the same thing but have had mixed results. The method described above works every time for me. Enjoy!!!

    Of course, if someone already knows (or guesses) a file name within that directory, they will still be able to access it from the public web. Adding an index.htm file only prevents the directory contents from being displayed in it's file structure.

    ~~RMIGHTY1
     
    #3 RMIGHTY1, Aug 31, 2007
    Last edited: Aug 31, 2007
  4. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    817
    Likes Received:
    22
    Trophy Points:
    18
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    Back to the original question...all you have to do is add this to your .htaccess:

    DirectoryIndex login.php

    You can specify the order that you want Apache to look for the files, just by tacking on the filenames...

    DirectoryIndex login.php index.php somepage.php
     
  5. Azraell

    Azraell Member

    Joined:
    Aug 2, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Brasil / Rio de Janeiro
  6. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    817
    Likes Received:
    22
    Trophy Points:
    18
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    That would just redirect everything to whatever page he has listed....he simpley wants the server to LOOK for login.php instead of index.* . That's what DirectoryIndex does, so all he has to do is change it.
     
Loading...

Share This Page