How to redirect a subdomain to another website? [closed]

感情迁移 提交于 2019-12-13 18:33:48

问题


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?


回答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.




回答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 call window.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.

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/




回答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.




回答4:


I am not familiar with www.000webhost.com, but if they are using cPanel, you should be able to do this very easily from within cPanel. Just select "Redirects" in the "Domains" section.




回答5:


Having your site behind CloudFlare is a good idea to begin with, but if redirection is all you want, they offer "Page Rules"



来源:https://stackoverflow.com/questions/11486402/how-to-redirect-a-subdomain-to-another-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!