How to redirect from www.mysite.com/directory to www.anothersite.com ?

Discussion in 'Apache' started by dynn, Feb 21, 2007.

  1. #1
    dynn, Feb 21, 2007 IP
  2. tnd

    tnd Well-Known Member

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #2
    put this in your .htaccess file

    
    Options +FollowSymLinks 
    
    RewriteEngine On 
    
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteCond %{HTTP_HOST} ^(www\.)?(anothersite)\.com$ [NC] 
    RewriteRule ^(.*)$ /%2/$1 [QSA,L]
    
    Code (markup):
    Hope this can help
     
    tnd, Feb 21, 2007 IP
    dynn likes this.
  3. dynn

    dynn Notable Member

    Messages:
    5,047
    Likes Received:
    238
    Best Answers:
    0
    Trophy Points:
    253
    #3
    thanks i will try this method.
     
    dynn, Feb 21, 2007 IP
  4. tespio

    tespio Peon

    Messages:
    16
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Or you can doit in php (if your hosting offers you php) like this

    on the first domain root directory put the next index.php file:

    index.php content follows:
    
    <?php
    header('Location: http://www.secondomain.com/');
    ?>
    
    Code (markup):
     
    tespio, Feb 26, 2007 IP