Urgent :: How to redirect www.domain.com/forums to forums.domain.com

Discussion in 'Programming' started by sweet_user, Apr 17, 2007.

  1. #1
    I want to redirect www.domain.com/forums to forums.domain.com and also dont want to lose my visitors from SE

    i tries using

    <?php
    $URL="http://www.forums.mysite.com/";
    header ("Location: $URL");
    ?> 
    
    Code (markup):
    but it just redirects www.domain.com/forums to forums.domain.com and not

    www.mysite.com/forums/forumdisplay.php?f=2 to forums.mysite.com/forumdisplay.php?f=2

    or

    www.mysite.com/forums/showthread.php?t=2835 to
    forums.mysite.com/showthread.php?t=2835

    How do i get the later two working...
     
    sweet_user, Apr 17, 2007 IP
  2. nikolaz

    nikolaz Peon

    Messages:
    119
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should create .htaccess file and put there:
    RewriteEngine On
    RewriteRule ^/forums/(.*) http://forums.mysite.com/$1 [R,L]
     
    nikolaz, Apr 17, 2007 IP
  3. nikolaz

    nikolaz Peon

    Messages:
    119
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Or you can use this php code:
    <?php
    $URL=preg_replace("/^\/forums\/(.+)/", "http://forums.mysite.com/$1", $_SERVER['REQUEST_URI']);
    header ("Location: $URL");
    ?>
     
    nikolaz, Apr 17, 2007 IP
  4. hclhost.com

    hclhost.com Banned

    Messages:
    257
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it easil as told by nikloas and u can also do it from c panel if u r using the cpanel
     
    hclhost.com, Apr 17, 2007 IP
  5. sweet_user

    sweet_user Peon

    Messages:
    238
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    where and how to use this code plz help me i only know little abt php ot htaccess file



     
    sweet_user, Apr 20, 2007 IP