how to redirect "dir/" to "dir/page.php"

Discussion in 'Apache' started by mameha1977, Oct 4, 2007.

  1. #1
    Simple question but, how to redirect all requests to a page using htaccess?

    I want the url to look like this:

    www.domain.com/dir/?u=1&p=2

    and redirect to:

    www.domain.com/dir/page.php?u=1&p=2

    Thanks.
     
    mameha1977, Oct 4, 2007 IP
  2. GMROCKS

    GMROCKS Active Member

    Messages:
    648
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #2
    make your index.php in /dir/ forward everything to page.php.
     
    GMROCKS, Oct 4, 2007 IP
  3. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #3
    or set your server to accept page.php as an index page
     
    jmhyer123, Oct 4, 2007 IP
  4. mameha1977

    mameha1977 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think my message was not clear, sorry. I am making an email magazine and I want to use URLs in the email to look like this:

    www.domain.com/dir/?u=1&p=2

    When they click the link, apache should somehow use this page to process:

    www.domain.com/dir/redirect_script.php?u=1&p=2

    and that will fetch the real url from the key in $_GET['u'] to redirect the user to the real url:

    www.domain.com/amazing-page.html

    Question: how to get apache to use 'redirect_script.php' in this example?
     
    mameha1977, Oct 4, 2007 IP
  5. mameha1977

    mameha1977 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    PS: I think the solution is to put a htaccess in /dir/ that redirects everything to redirect_script.php, but I don't know what command to use in the htaccess.
     
    mameha1977, Oct 4, 2007 IP
  6. mameha1977

    mameha1977 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    the answer:

    DirectoryIndex redirect_script.php
     
    mameha1977, Oct 4, 2007 IP