SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Is there a way to get this by .htaccess file?

    n my site root directory. there are donghua.php and index.php. now, is there a way to use .htaccess file to let the visitor access my site .the default shows example.com/donghua.php. not example.com/index.php. thank you. the server is Apache.

    ps:The user still can access example.com/index.php

    i using
    Code:
    DirectoryIndex donghua.php
    in the .htaccess. the default page is ok. but when i access example.com/index.php it redirect to example.com/donghua.php. if i forbid it redirect how do i do?

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,263
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    So... the problem is that index.php redirects to donghua.php, but you don't want that to happen?

    If that's your question, then we're going to need more information. Either one of your other htaccess rules is causing the redirect, or something in index.php is causing the redirect. We can't check either one unless you show them to us.
    "First make it work. Then make it better."

  3. #3
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    when access the site(http://www.example.com). i want it shows the content(http://www.example.com/donghua.php). and when i access http://www.example.com/index.php directly, it also work.

  4. #4
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,824
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by runeveryday View Post
    when access the site(http://www.example.com). i want it shows the content(http://www.example.com/donghua.php). and when i access http://www.example.com/index.php directly, it also work.
    Is this what you want to happen when these URI are called:

    1. "http://www.example.com/" goes to "http://www.example.com/donhua.php"

    2. "http://www.example.com/donhua.php" goes to "http://www.example.com/donhua.php"

    3. "http://www.example.com/index.php" goes to WHERE EXACTLY

  5. #5
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John_Betong View Post
    Is this what you want to happen when these URI are called:

    1. "http://www.example.com/" goes to "http://www.example.com/donhua.php"

    2. "http://www.example.com/donhua.php" goes to "http://www.example.com/donhua.php"

    3. "http://www.example.com/index.php" goes to WHERE EXACTLY
    yes, you are right. http://www.example.com/index.php go to http://www.example.com/index.php

  6. #6
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,824
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Why not follow standard practise and make items one and three activate index.pup and donhua.php to go to a separate page?

  7. #7
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John_Betong View Post
    Why not follow standard practise and make items one and three activate index.pup and donhua.php to go to a separate page?
    in donghua.php i invoke a flash. so i want to when the user access the site it will show the flash. there is a link on the flash. (enter the site)example.com/index.php

  8. #8
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,824
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    I have searched and unable to find a .htaccess solution to your problem.

    Can you post a link to your site and other posters may be able to help.

  9. #9
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John_Betong View Post
    I have searched and unable to find a .htaccess solution to your problem.

    Can you post a link to your site and other posters may be able to help.
    http://www.hf-cgp.com/donghua.php

    i want to access the site(http://www.hf-cgp.com/) shows the flash http://www.hf-cgp.com/donghua.php . then click enter the site(at bottom of the site.) the site is made by wordpress.

  10. #10
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,824
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by runeveryday View Post
    http://www.hf-cgp.com/donghua.php

    i want to access the site(http://www.hf-cgp.com/) shows the flash http://www.hf-cgp.com/donghua.php . then click enter the site(at bottom of the site.) the site is made by wordpress.
    Why not have a splash screen with two links:

    http://johns-jokes.com/downloads/sp-b/donhua/

  11. #11
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    Create a .htaccess file in the root of your website and add this line to it:

    Code:
    DirectoryIndex donhua.php
    This should do what you want.

  12. #12
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi,

    Create a .htaccess file in the root of your website and add this line to it:

    Code:
    DirectoryIndex donhua.php
    This should do what you want.
    this made you can't access example.com/index.php. when your access it will redirect to example.com/donghua.php

  13. #13
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John_Betong View Post
    Why not have a splash screen with two links:

    http://johns-jokes.com/downloads/sp-b/donhua/
    how to make when the user open the site. it shows http://johns-jokes.com/downloads/sp-b/donhua/

  14. #14
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,824
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by runeveryday View Post
    how to make when the user open the site. it shows http://johns-jokes.com/downloads/sp-b/donhua/
    Just modified the link:

    1. No .htaccess required
    2. index.php now has source displayed at the bottom of the page
    3. index.php has two buttons, one links to the donhua.php the other to a new index_main.php
    4. index.php now loads very quickly

  15. #15
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by runeveryday View Post
    this made you can't access example.com/index.php. when your access it will redirect to example.com/donghua.php
    That's weird, it shouldn't!
    Try clearing your cache to ensure that your browser hasn't cached a previous redirect.

    Here's an example demonstrating that it does work.

    I created a directory entitled "directoryIndex-example"
    In this directory I placed three files, "index.php", "donhua.php" and a .htaccess file.
    The .htaccess file contained this:
    Code:
    DirectoryIndex donhua.php
    Now, if you go to the following url, you are directed to donhua.php
    http://hibbard.eu/blog/pages/directoryIndex-example/

    However, if you navigate to either file directly, then things still work as expected:
    http://hibbard.eu/blog/pages/directo...mple/index.php
    http://hibbard.eu/blog/pages/directo...ple/donhua.php


    Saying all of that, I find John's solution much better, as it gives your visitors a choice in what they look at.
    Also, remember that iOS devices don't support Flash.


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
  •