Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Redirect

  1. #1
    New Coder
    Join Date
    Jul 2008
    Location
    Manila, PH
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Redirect

    Hi!

    I'd like to ask how to redirect from one PHP to another PHP provided that they are in a different directory. I already found a code that can redirect from one PHP page to another PHP page. However, that is only in the same directly. The code is shown below:

    PHP Code:
    <?php
    /* Redirect to a different page in the current directory that was requested */
    $host  $_SERVER['HTTP_HOST'];
    $uri   rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra 'anotherpage.php';
    header("Location: http://$host$uri/$extra");
    exit;
    ?>
    I'd like to know how to redirect to another page in an upper directory.

    ----> index.php
    ----> idliketogohere.php
    [subfolder]
    --> currentpage.php
    --> anotherpage.php

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Use the complete URL.

    PHP Code:
    header("Location: http://www.mysite.php/folder/folder/file.php"); 


    ------------
    Leonard Whistler

  • #3
    New Coder
    Join Date
    Jul 2008
    Location
    Manila, PH
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    I discovered the answer. Here:

    PHP Code:
    $host  $_SERVER['HTTP_HOST'];
    $folder "lotcheckeditor";

    header("Location: http://$host/$folder/pages/sorry.html"); 
    Last edited by mpacaon; 08-15-2008 at 06:38 AM.


  •  

    Tags for this Thread

    Posting Permissions

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