How to redirect a subdomain to a subdirectory

Programming, error messages and sample code > sample code
You can redirect a subdomain to a subdirectory by using ASP or code.

When the requests are redirected using an ASP file, the URL in browser for redirected domains will show the correct domain name and the directory name where the request is being redirected. You can also redirect the requests to a specific file.

For example: --> --> -->

The following is a sample script that you can use to redirect a subdomain. You will need to place it as default document on your document root.

If InStr( UCase(Request.ServerVariables("SERVER_NAME")),  UCase("") ) > 0 Then 
ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("") ) > 0 Then 
ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("") ) > 0 Then 
End If 

  1. Replace with your actual subdomain URL.
  2. Replace /subdomain with your actual subdirectory name.