How to make a subfolder into a page??

Discussion in 'HTML & Website Design' started by themetalpeddler, Apr 4, 2006.

  1. #1
    How do some websites have, for example, www.domianname.com/folder/ as a viewable page? Mine just show up as a directory index and I cannot fathom how to make it into something else.

    Any help? Thanks!
     
    themetalpeddler, Apr 4, 2006 IP
  2. iatbm

    iatbm Prominent Member

    Messages:
    5,151
    Likes Received:
    352
    Best Answers:
    0
    Trophy Points:
    360
    #2
    just make index.html or index.php there and you are good
     
    iatbm, Apr 4, 2006 IP
  3. MKInfo

    MKInfo DP Guard Dog

    Messages:
    1,481
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Every folder must have an index file.Its the first thing a browser looks for.Otherwise,as you have found,you will just get a list of files.
     
    MKInfo, Apr 4, 2006 IP
  4. themetalpeddler

    themetalpeddler Peon

    Messages:
    108
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I can't believe I didn't think of that! LOL Thanks!
     
    themetalpeddler, Apr 4, 2006 IP
  5. themetalpeddler

    themetalpeddler Peon

    Messages:
    108
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    MK, I never knew that! Duh me! Thanks. I'm re-designing the whole thing right now so good chance to get it right 2nd time around :)
     
    themetalpeddler, Apr 4, 2006 IP
  6. MKInfo

    MKInfo DP Guard Dog

    Messages:
    1,481
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    140
    #6
    Don't put yourself down.We all got to learn somewhere.Thats one of the fun things about it.It's really great after hours of frustration and hard work to finally get it right and see the final result.
    Good luck with your site.:)
     
    MKInfo, Apr 4, 2006 IP
  7. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    it may also be mod rewrite at work?
     
    rosytoes, Apr 8, 2006 IP
  8. ajshroff

    ajshroff Peon

    Messages:
    165
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You are right MK and this where this site helps us a lot.
     
    ajshroff, Apr 8, 2006 IP
  9. brian394

    brian394 Well-Known Member

    Messages:
    226
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #9
    Yes, as MKInfo said if one of the following files is present in the directory it will be shown instead of a directory list...

    index.htm, index.html, index.shtml, index.php, default.htm, default.html, etc.

    You can also use a .htaccess file. Here's how:

    1.) Create a file called .htaccess in your root directory
    2.) Open the .htaccess file in Notepad and type the following...

    RewriteEngine on
    RewriteRule ^folder/$ test.php

    The ^ is the start of line anchor and the $ is the end of line anchor. Anything in between that is what the person is requesting. What comes after the $ is what should be returned instead.

    That means whenever somebody requests this URL...

    www.domainname.com/folder/

    test.php will be returned instead. In the person's address bar it will still read..

    www.domainname.com/folder/

    but if you look at the actual source code of the page it will be test.php. That is the power of mod_rewrite. mod_rewrite can also do a lot of other cool stuff with regular expressions. Do a search for mod_rewrite in Google to learn more. You can also control what files are interpreted as index files. For example, let's say I had a file "abc.html" that I wanted to be the index of a directory. That means whenever somebody types in...

    www.domainname.com/folder/

    what I want to actually show up is...

    www.domainname.com/folder/abc.html

    but I want the address bar of their browser to still read...

    www.domainname.com/folder/

    That is called the index file. You can do that by using the following command in your .htaccess file...

    DirectoryIndex abc.html index.htm index.html index.shtml index.php default.htm default.html

    Do a search for DirectoryIndex Directive in Google to learn more.
     
    brian394, Apr 8, 2006 IP