Redirecting sub-domain.

4 replies
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 topnichewebsites
    You can re-direct your domains in your CPANEL or via .htaccess file and can make them perma

    Avoid using php to redirect
    Signature
    http://pixelcovers.com/ <- eBook add eCovers

    https://www.unicommercesolutions.com <- WordPress Websites and Maintenance
    {{ DiscussionBoard.errors[7279811].message }}
  • Profile picture of the author eminc
    Hey,

    Create Subdomains via cPanel, it asks you for a document root(different folder in your /public_html directory). Specify a different folder there.

    Suppose you create a sub domain a.mysite.com, then it will be found in your file manager as /public_html/a

    After that create a file index.htm under this folder with the contents

    <meta http-equiv="refresh" content="0;url=http://example.com/new.html">

    Will do a 301 redirect to your new page.


    -Mohit
    Signature

    The best way to predict future is to create it ― Abraham Lincoln

    {{ DiscussionBoard.errors[7280575].message }}
  • Profile picture of the author Jr180180
    It'll probably be less work if you just do it through cPanel... Assuming you have a hosting provide with cPanel. Check out "Enable or Disable Subdomain Redirection" at Subdomains
    Signature

    Sharing the love!

    Easy-to-Install Wordpress Plugin - SMS Points System
    Get started on DigitalOcean with DOCasts!

    {{ DiscussionBoard.errors[7281824].message }}
  • Profile picture of the author y8y8
    in PHP use header("location: URL");
    and
    in HTML use <meta http-equiv="refresh" content="DELAY TIMES;url=URL">
    {{ DiscussionBoard.errors[7281973].message }}

Trending Topics