i have a host and domain on godaddy, i have a subdomain like : sub1.mydomain.com. Now my friend has another domain like myfrienddomain.com and he point to my host.

How can i point his domain to my subfolder sub1. Everytime he open myfrienddomain.com it will show my site on sub1.mydomain.com. Currently he show mine mydomain.com sites.

Is this possible ,please help me!

Sr if there is duplicated post, i search for over 45 page on stackoverflow and 1 post said i should post on this sites

  • You refer to a "subdomain like sub1" in the first paragraph, but state "subfolder sub1" in the second. I assume you mean "subdomain"? However, this appears to have created some confusion in the answers below. Can you please clarify. How are you currently "pointing" myfrienddomain.com to mydomain.com? Which domain do you wish to show in the address bar?
    – MrWhite
    Apr 17, 2015 at 8:10
  • he pointed myfrienddomain.com to mydomain.com. But his sites is on the sub1.mydomain.com and my site on mydomain.com. Now i just want everytime someone link to myfrienddomain.com it will show site on sub1.mydomain.com. Is that help ?
    – Hung Lam
    Apr 17, 2015 at 9:52

3 Answers 3


There are 2 real solution ( not the redirecting thing)

  1. Using 'Domain Masking' ( google it)

  2. You want otherdomain.com to show the sub1.maindomain.com/folder

You can do the following .

• create a sub2.maindomain.com And configure it with the server so that it displays the sub1/folder

• Create a CNAME Record on otherdomain.com that points to sub2.maindomain.com

  • 1
    In this case, the OP seems to making the mistake of calling a sub-domain a sub folder.
    – closetnoc
    Apr 17, 2015 at 6:18
  • He said subfolder , he meant subdomain's subfolder
    – AlhasanIQ
    Apr 17, 2015 at 6:19
  • I don't believe he means that at all. It is not uncommon that people come here and use the term sub folder for sub-domain. I did not see any reference to a folder in his question. BTW- I am not being critical of you or your answer. Just trying be be informative. We get this a lot here. I am glad you are here and jumping in!
    – closetnoc
    Apr 17, 2015 at 6:23
  • I think this makes sense . You are right probably
    – AlhasanIQ
    Apr 17, 2015 at 6:25
  • Trust me- I read the question a couple of times- it is really confusing. It is easy to misread these questions. It is still possible he means folder. Who really knows for sure? Not me. I am just guessing based on what I have seen in the past. BTW- Welcome to the site!!
    – closetnoc
    Apr 17, 2015 at 6:27

An easy way to do it in PHP is to create index.php on the site that needs to be redirected:

header("HTTP/1.1 301 Redirect",true);
header("Location: http://example.com/folder",true);
?><html><head><title>Redirect</title></head><body><a href="http://example.com">Click here to continue</a></body></html>

Just replace example.com with the domain you want the redirection to go to.

In your case, make index.php in the document root of the domain:


Then make your index.php contain the following:

header("HTTP/1.1 301 Redirect",true);
header("Location: http://sub1.mydomain.com",true);
?><html><head><title>Redirect</title></head><body><a href="http://sub1.mydomain.com">Click here to continue</a></body></html>

sub1 is a subdomain here.


The absolute simplest thing to do is create a CNAME record in your DNS that points myfrienddomain.com to sub1.mydomain.com and make sure there is no A record for myfrienddomain.com. You do not need a redirect. Let DNS do the work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.