Does anyone know of a script that can check if domain2.com is typed in the address and if it is then forward to domain1.com/subdirectory
That would be terrific! Thanks.

Moderators: egami, macek, gesf
Code: Select all
<?php
header("Location: http://www.domain1.com/subdirectory");
?>
Code: Select all
'**************************************
' Name: Multi Domain Redirect
' Description:If you have multiple domai
' n names pointing to the same web site, t
' his code will allow you to redirect the
' user to a subdirectory based on the web
' address then type in the browser.
' By: Glenn C.
'
'This code is copyrighted and has ' limited warranties.Please see http://w
' ww.Planet-Source-Code.com/vb/scripts/Sho
' wCode.asp?txtCodeId=6349&lngWId=4 'for details. '**************************************
<%@ Language=VBScript %>
<%
' Set up your variables
Dim sURL, sPath
' Get the domain name typed in the brows
' er.
sURL = Request.ServerVariables("HTTP_HOST")
' Get the rest of the path after the dom
' ain name.
sPath = Request.ServerVariables("PATH_INFO")
' Based on the domain name, redirect the
' user
' to the correct directory and attach th
' e rest
' of the path.
Select Case sURL
Case "www.maindomain.com", "maindomain.com"
' Ignore...this is the current site.
Case "www.domain2.com", "domain2.com"
' redirect To the "domain2" directory
Response.Redirect "domain2" & sPath
Case "www.domain2.net", "domain2.net"
' redirect to the "domain2net" directory
'
Response.Redirect "domain2net" & sPath
End Select
%>
Code: Select all
<?php
if ($_SERVER['SERVER_NAME'] == "www.domain2.com" || $_SERVER['SERVER_NAME'] == "domain2.com") {
header("Location: http://www.domain2.com/sub");
}
?>