SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard realestate's Avatar
    Join Date
    May 2004
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you make a file default?

    If someone visits domain.com usually he is redirected to index.html

    Is this really a redirect? Is there a way to make a specific file default file?

    301 and 302 redirect both seem to have advantages and disadvantages.

    I am interested in the php case. Our site is in php and we redirect site to
    site/home.php.

  2. #2
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A server will typically try to find the default file to display for a given domain name, that is default.html, index.html, index.php etc...

    Here what you want to do. Create an index.php file. This page should only have the following code at its top:

    PHP Code:
    <?php
    header
    ('Location: http://www.domain.com/site/home.php');
    exit;
    ?>
    Everytime someone access your site via the domain name (without specifying any page), he/she will be redirected to the appropriate page.

    If you can use .htaccess files, note that the DirectoryIndex directory controls the default page. You can use something like this:
    Code:
    DirectoryIndex site/home.php
    Save it as a .htaccess file and place it in the directory where you want your server to look for the custom homepage.

    More info:

    http://httpd.apache.org/docs/mod/mod...directoryindex
    Last edited by duuudie; Jan 29, 2005 at 11:40. Reason: link to Apache Doc added

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by realestate
    If someone visits domain.com usually he is redirected to index.html

    Is this really a redirect?
    No, it's more like an alias. / becomes an alias for /home.php. The browser doesn't know it happened.

    Quote Originally Posted by realestate
    Is there a way to make a specific file default file?
    DirectoryIndex home.php
    in a .htaccess file


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •