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 4 of 4
  1. #1
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto re-direct with a twist.

    hi,

    i have two domain names e.g one and two, one being the master. they both point to the same index page, in the same location as to where they are stored.

    if you went to domain two, i want it to re-direct to domain one (master) automatically, i've tried using the refresh meta tag way, which works but it stays in a refresh loop, obvisously because it's accessing the same index page, is there away of just executing the redirect once, as i dont want to point each domain at a different page.

    thanks in advance.

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Your best and safest bet (from a search engine pov) is to use a server-side redirect such as a 301 redirect or equivalent to discreetly reroute requests for domain2 to domain1.

    You'll need to establish domain2 with its own root directory structure first, then implement the 301 redirect method via the .htaccess file in the root directory of domain2.

  • #3
    Regular Coder
    Join Date
    May 2006
    Location
    Bristol, UK
    Posts
    147
    Thanks
    6
    Thanked 2 Times in 2 Posts
    try this:-

    Code:
    <?php
    
    header("HTTP/1.1 301 Moved Permanently");  
    header("Location: http://www.example-new.com" . 
     $_SERVER['SCRIPT_NAME'] . '?' .  
     $_SERVER['QUERY_STRING']);  
    exit();
    
    ?>
    Jon

    EDIT: Snap!

  • #4
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for that guys i'll have a look.


  •  

    Posting Permissions

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