How can I redirect to my site from another?

Discussion in 'PHP' started by kalidas, Jan 13, 2010.

  1. #1
    I have developed a site named www.printingchemical.com, full of information portal on chemicals.

    I have another two domains.
    How can I make a code to redirect from that two domain to my www.printingchemical.com site?

    Waiting for this code.

    Thanks in advance.
     
    kalidas, Jan 13, 2010 IP
  2. SecureCP

    SecureCP Guest

    Messages:
    226
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    SecureCP, Jan 13, 2010 IP
  3. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Put this in a .htaccess file in the root folder of your other two domains
    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^/?(.*)$ http://www.printingchemical.com/$1 [R=301,L]
    
    Code (markup):
     
    JAY6390, Jan 13, 2010 IP
  4. t6werserv

    t6werserv Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    code:
    <?
    echo'<script>window.location="example.com?example";</script>';
    ?>
     
    t6werserv, Jan 16, 2010 IP
  5. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #5
    Javascript can be disabled, so its not reliable.

    Theirs many ways:

    1. .htaccess

    2. php header location

    3. html meta refresh tag

    4. javascript - window.location

    But i'd recommend 1 and 2 since they don't rely on client-side configuration, theirfore more reliable.
     
    danx10, Jan 16, 2010 IP
  6. t6werserv

    t6werserv Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This code works under Java scripts with PHP Code
    Example:

    <?
    $p=$_GET['p'];
    $display ="SELECT * FROM tbl_data WHERE p='$p'";
    $result=mysql_query($display);
    $display= mysql_fetch_array($result);
    echo'<script>window.location="index.php?menu";</script>';
    ?>

    index.php?menu ex:(go to menu page)
     
    t6werserv, Jan 16, 2010 IP
  7. dmanto2two

    dmanto2two Peon

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    header is very reliable in my experience.
    can also be used for refresh which is useful in conditional functions.
     
    dmanto2two, Jan 16, 2010 IP