|
<% SiteNameURL = Request.ServerVariables("SERVER_NAME")
Select Case SiteNameURL Case "yourdomain.com" %><!-- #Include File="page1.asp" --><%
Case "www.yourdomain.com" %><!-- #Include File="page1.asp" --><%
Case "yourotherdomain.com" %><!-- #Include File="page2.asp" --><%
Case "www.yourotherdomain.com" %><!-- #Include File="page2.asp" --><%
Case "subdomain1.yourdomain.com" %><!-- #Include File="page3.asp" --><%
Case "subdomain2.yourdomain.com" %><!-- #Include File="page4.asp" --><%
Case Else 'redirecting everything other than cases selected above %><!-- #Include File="other.asp" --><% End Select %> |
The following is an example of ASP code. You will need to save the page as default.asp or index.asp.
This code sample will redirect visitors to the corresponding page, changing the URL, for example http://domain.com/page1.asp.
|
<% SiteNameURL =? Request.ServerVariables("SERVER_NAME")
Select Case SiteNameURL Case "yourdomain.com" Response.Redirect "page1.asp"
Case "www.yourdomain.com" Response.Redirect "page1.asp"
Case "yourotherdomain.com" Response.Redirect "page2.asp"
Case "www.yourotherdomain.com" Response.Redirect "page2.asp"
Case "subdomain1.yourdomain.com" Response.Redirect "page3.asp"
Case "subdomain2.yourdomain.com" Response.Redirect "page4.asp"
Case Else 'redirecting everything other than cases selected above Response.Redirect "other.asp" End Select %> |
The following is an example of PHP code. You will need to save the page as default.php or index.php.
This code sample will redirect visitors to the corresponding page, changing the URL, for example http://domain.com/page1.php.
All domain names entries should be lower case.
|
<? $SiteNameURL = $_SERVER['HTTP_HOST'];
switch (strtolower($SiteNameURL)) {
case "domain.com": //MUST BE LOWER CASE
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/page1.php"); break;
case "www.domain.com": //MUST BE LOWER CASE
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/page1.php"); break;
case "yourotherdomain.com": //MUST BE LOWER CASE
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/page2.php"); break;
case "www.yourotherdomain.com": //MUST BE LOWER CASE
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/page2.php"); break;
case "subdomain1.domain.com": //MUST BE LOWER CASE
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/page3.php"); break;
case "subdomain2.domain.com": //MUST BE LOWER CASE
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/page4.php"); break;
default: header("Location: http://" . $_SERVER['HTTP_HOST'] . "/other.php");
} ?> |
The following is an example of PHP code. You will need to save the page as default.php or index.php.
This code sample will *include* content from another page, leaving the URL in the URL bar of the web browser alone.
All domain names entries should be lower case.
|
<? $SiteNameURL = $_SERVER['HTTP_HOST'];
switch (strtolower($SiteNameURL)) {
case "domain.com": //MUST BE LOWER CASE include 'page1.php' break;
case "www.domain.com": //MUST BE LOWER CASE include 'page1.php' break;
case "yourotherdomain.com": //MUST BE LOWER CASE include 'page2.php' break;
case "www.yourotherdomain.com": //MUST BE LOWER CASE include 'page2.php' break;
case "subdomain1.domain.com": //MUST BE LOWER CASE include 'page3.php' break;
case "subdomain2.domain.com": //MUST BE LOWER CASE include 'page4.php' break;
default: include 'other.php'
} ?> |
The following example uses JavaScript code. You will need to save the page as an HTML document, using .html or .htm as the file extension. This code sample will redirect visitors to the corresponding page, changing the URL, for example http://domain.com/page1.php.
|
<html> <head> var whois=location+" "
if (whois.indexOf("yourdomain.com") != -1) { window.location ="page1.html" }
if (whois.indexOf("www.yourdomain.com") != -1) { window.location ="page1.html" }
if (whois.indexOf("yourotherdomain.com") != -1) { window.location ="page2.html" }
if (whois.indexOf("www.yourotherdomain.com") != -1) { window.location ="page2.html" }
if (whois.indexOf("subdomain1.yourdomain.com") != -1) { window.location ="page3.html" }
if (whois.indexOf("subdomain2.yourdomain.com") != -1) { window.location ="page4.html" }
</head> <body> </body> </html> |
domainredirect subdomain
Tags: -
Related entries:
Last update: 2009-12-21 11:14
Author: Administrator
Revision: 1.1