Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    999

    Multiple domain redirect

    Hi,

    I've a domain working on Apache/2.0.59 (Win32) mod_jk/1.2.18 PHP/4.4.4 setup. It works fine, but I recently configured another domain on the same server. Nameservers and everything is fine but the new domain points to the location of old domain.

    Is there any way, using PHP, to redirect both domains to different locations?

    For a single domain redirect, I used this so far:

    Code:
    <?php
    header("Location: v/index.jsp"); /* Redirect browser */
    
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    ?>
    I tried this for multiple domain redirect, but it doesn't work:

    Code:
    <?php
    header("Location: http://domain1.com" . $_SERVER['HTTP_HOST']
                         . dirname($_SERVER['PHP_SELF'])
                         . "/dir/file.ext" . $relative_url);
    
    header("Location: http://domain2.com" . $_SERVER['HTTP_HOST']
                         . dirname($_SERVER['PHP_SELF'])
                         . "/dir/file.ext" . $relative_url);
    ?>
    Any help greatly appreciated.

    Thanks.

  2. #2
    Join Date
    May 2006
    Location
    Teh Interweb
    Posts
    314
    The second batch of code is not working because you cannot redirect to two different places with the php header() function.

    I am not quite sure what you are trying to accomplish here. Please attempt to explain your problem in more detail and site examples if possible.

    Is the problem that domain2.com's root directory is the same as domain1.com?

    [[email protected]] ~ $ cat .signature
    cat: .signature: No such file or directory

Posting Permissions

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