Web Hosting Talk







View Full Version : How do I forward to subdomain


johntech
12-21-2007, 08:54 AM
Hello

I want to forward my domain www.mydomain.com (http://www.mydomain.com) to www.mydomain.com/home (http://www.mydomain.com/home)

How do I do that? Thanks a lot.

kohashi
12-22-2007, 12:39 AM
many ways, you could use a frame, or a simple redirect script (javascript) would be the easiest ways.

rony
12-22-2007, 08:15 AM
I would not use javascript as this gets executed on the client site and not everybody has javascript enabled and not all robots follow javascript.

You can make in your webroot an index.php file (when you have php support) with the following content:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.mydomain.com/home/");
exit;
?>


Or on an apache server you can make a .htaccess file with the following content:

Redirect permanent / http://www.mydomain.com/home/

(didn't tested that, but should work).

gUrUs
12-23-2007, 04:48 PM
Or for ASP.NET in codebehind for Default.aspx use (on C#)

string sname = Request.ServerVariables("SERVER_NAME");
sname = sname.ToUpper();
if (sname.Contains("www.mydomain.com") != 0)
{
Response.Redirect("http://www.mydomain.com/home/");
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "home");
}

Tested!