How to put redirect

Discussion in 'PHP' started by toxic1985, Jul 14, 2008.

  1. #1
    i've an website in phpbb.
    and i want to put there a redirect link. i try to find in google. bt didn't get any.

    can anyone help me in this

    Thankyou
    Toxic1985
     
    toxic1985, Jul 14, 2008 IP
  2. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #2
    <?php 
    Header("HTTP/1.1 301 Moved Permanently"); 
    Header("Location:http://www.yourforums.com"); 
    ?>
    Code (markup):
     
    mokimofiki, Jul 14, 2008 IP
  3. Neavix

    Neavix Peon

    Messages:
    72
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just a question mokimofiki, or any one else in fact.

    There is no need for
    ... right? I thought
    would do the job just fine?
     
    Neavix, Jul 14, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    No, that will send a default 302 header... not 301.

    But an easier way:

    header('Location: http://www.yourforums.com', true, 301); //Redirect with 301
    PHP:
     
    Danltn, Jul 14, 2008 IP
  5. mzonas

    mzonas Well-Known Member

    Messages:
    721
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    160
    #5
    what is the difference between 301 and 302 headers?
     
    mzonas, Jul 14, 2008 IP
  6. web_doctor

    web_doctor Peon

    Messages:
    164
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you could also try javascript with this codes:
    <script language="javascript">window.location="yoursite.com/";</script>

    and thats it....
     
    web_doctor, Jul 14, 2008 IP
  7. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #7
    The idea of a 301 header is sometimes (perhaps even normally) used to be search engine friendly, a javascript solution is definitely not search engine friendly.

    301 is perm moved. (example: PR is not accumulated, but forwarded.)
    302 is temp moved.
     
    Danltn, Jul 14, 2008 IP
  8. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #8
    shallowink, Jul 14, 2008 IP
  9. locjan

    locjan Peon

    Messages:
    201
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i suggest not if you want to get instant PageRank
     
    locjan, Jul 14, 2008 IP
  10. toxic1985

    toxic1985 Active Member

    Messages:
    632
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #10
    thanx for everyone.
    but i don't want to redirect my site.

    i want to redirect my each download link. if users click these download link they will redirect a page where they wait for few sec then download start automatically.

    i need this.

    <?php
    /* Redirect to a different page in the current directory that was requested */
    $host = $_SERVER['HTTP_HOST'];
    $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra = 'mypage.php';
    header("Location: http://$host$uri/$extra");
    exit;
    ?>
    what to add in this code if my site is www.yoursite.com
     
    toxic1985, Jul 14, 2008 IP
  11. Highwayman

    Highwayman Peon

    Messages:
    117
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Modifying the htaccess file is the easiest way. Just write this:
    
    Redirect 301 / http://www.example.com/
    Code (markup):
     
    Highwayman, Jul 15, 2008 IP
  12. Neavix

    Neavix Peon

    Messages:
    72
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Yeah, but not all hosts allow you to edit the htaccess file ;)
     
    Neavix, Jul 15, 2008 IP
  13. Highwayman

    Highwayman Peon

    Messages:
    117
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    True, but a lot of them do. It's worth trying to start with as it saves having to add more code to your actual pages, if you can do it.
     
    Highwayman, Jul 16, 2008 IP
  14. sastro

    sastro Well-Known Member

    Messages:
    214
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #14
    Put these all

     
    sastro, Jul 16, 2008 IP