Redirecting sub-domain.

2 replies
  • WEB DESIGN
  • |
Hi,

Firstly, I have done a search and could not find exactly what I wanted, so I thought I would start a new thread.

I am wondering if anyone could tell me how to redirect a sub domain to an external website. I have many sub domains all of which need to go to separate sites, i.e.:

a.mydomain.com redirects to a.com
b.mydomain.com redirects to b.com
etc.

I have found the following but I am not sure how to use it:

<?php
header( 'Location: http://www.domain.com' ) ;
?>

What do I cann the file that this goes in?

If there's a better way than the above, I'm all ears.

Thanks in advance,

Ryan.
#redirecting #subdomain
  • Profile picture of the author webhosting
    1. Create a file called index.php

    2. For redirecting a.mydomain.com to a.com put this code in the index.php:
    <?php
    header( 'Location: http://www.a.com' ) ;
    ?>

    3. Upload index.php to a.mydomain.com root. Now, when the visitor comes to a.mydomain.com, he will be automatically redirected to www.a.com.
    Signature
    MarbleHost.com - reliable web hosting since 2005
    {{ DiscussionBoard.errors[7279169].message }}
  • Profile picture of the author tronsmith
    Thank you!

    I'll give that a go!
    {{ DiscussionBoard.errors[7279174].message }}

Trending Topics