How to redirect a subdomain to another website?
Solution 1
Use either a .htaccess file or create a PHP script with the following:
<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://the-network-king.blogspot.in');
To create a 301 redirect.
and save the file under name index.php
else it wont pick up file.
Solution 2
Most domain name registrars provide a free redirection service, I think GoDaddy does too. Why not just do that?
If you want to get more technical, then redirection can be done (in code) in a few ways (in order of difficulty).
- Frames. Welcome back to 1999-2002. Just put a static HTML
<frameset>
page up and load your target page in a whole-page frame. Your users will hate you. -
<meta>
redirection. Another staple from the late-1990s school of web design. Put<meta http-equiv="refresh" content="5;URL='http://example.com/'" />
in your HTML page. - Javascript redirection. In a
<script>
block in your page callwindow.location = "http://www.example.com";
- Server-side redirection. All server-side redirections are done by setting the
Location:
HTTP header. How you do this depends on your server platform:- PHP:
header('Location: http://www.example.com');
- ASP:
Response.Redirect("http://www.example.com")
(also works for ASP.NET) - ASP.NET MVC:
return Redirect("http://www.example.com");
(call inside Controller action method) - .htaccess: A bit more complicated. See the link below.
- PHP:
There's a whole load of redirections in a variety of platforms and languages here: http://www.webconfs.com/how-to-redirect-a-webpage.php/
Solution 3
You could technically use the Go Daddy subdomain forwarding function from within your Domain Manager. http://support.godaddy.com/help/article/4040/managing-a-domain-names-forwarded-subdomains
Once added, you will need to point an A record subdomain from where your DNS is actually hosted (www.000webhost.com) to the Go Daddy forwarding IP 64.202.189.170.
Comments
-
jeet.chanchawat over 3 years
I bought domain www.mydomain.com from godaddy.com. I hosted it at www.000webhost.com (free web-domain-hosting site). I created a subdomain subdomain.mydomain.com through ccpanel of 000webhost.
I want that subdomain to be diverted to my blog http://myblog.blogspot.in/
Right now I have a folder named
subdomain
in my root folder. What shall I upload in that folder so that It gets redirected to my blog? -
jeet.chanchawat almost 12 yearsI added this code to a redirect.php file (7 hrs ago). uploaded it to that folder. dosen't seems to be working. I am getting 404 not found msg
-
Martin Bean almost 12 yearsWell you're obviously not viewing the right URL.
-
jeet.chanchawat almost 12 yearsI got to know what I was doing wrong... I named the file as redirect.php I must have named it index.php :)
-
jeet.chanchawat almost 12 yearsgodaddy is keeping a count of number of edits. So, I am avoiding edits through godaddy. after 100 edit counts it would again start aking for money.
-
Leo Prince almost 11 yearsTry "redirects" from cpanel and add the URL myblog.blogspot.in for your subdomain. If godaddy is not helping try reading another hosts blogs to create. See this linkhttp://support.hostgator.com/articles/cpanel/url-redirect-how-to-create
-
Leo Prince almost 11 yearsHi martin, comment is not for you :) I was telling to the jeet (who asked question) to read the blog to create redirects from cpanel. No worries :)