Reply to topic
ASP Redirect Help Needed Massiva
apexonelove


Joined: 30 Mar 2005
Posts: 7
Location: Utah
Reply with quote
Hey all. I'm just moving a site I designed over to HostMySite and I'm having a little trouble. Apparently, my previous host had something called redirection or supported subfolder directorizing through DNS. My trouble comes through trying to write an ASP script that is going to work as a redirector for their intranet site.

I want my users to be able to type in: "intranet.mdff.org" to their address bar and go to my intranet.mdff.org folder (which is located in the same directory as my main domain "www.mdff.org".

The following is the scripting I found through HostScripts.com and modified...I have no idea what I'm doing...I guess that's why I'm a designer and not a programmer... many if anyone could help me with this I would be most appreciative...most:



<%@LANGUAGE="VBSCRIPT"%>
<%
' Set up your variables
Dim sURL, sPath
' Get the domain name typed in the brows
' er.
sURL = Request.ServerVariables("http://intranet.mdff.org")
' Get the rest of the path after the dom
' ain name.
sPath = Request.ServerVariables("../intranet.mdff.org")
' 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.mdff.org", "mdff.org"
' Ignore...this is the current site.
Case "http://intranet.mdff.org", "intranet.mdff.org"
' redirect To the "domain2" directory
Response.Redirect "intranet.mdff.org" & sPath
Case "http://intranet.mdff.org", "intranget.mdff.org"
' redirect to the "domain2net" directory
'
Response.Redirect "http://intranet.mdff.org" & sPath
End Select
%>


I talked with some nice people at HostMySite and they told me that it looked like a combination of java in there too...I'm not really sure. HELP! You guys can email me at jhigley@powerfulimage.com if you want to aswell.

Much appreciated,
-Jonathan Confused Confused
bobum
Elvis Fanatic
Elvis Fanatic

Joined: 16 Nov 2004
Posts: 746
Location: Montgomery, AL
Reply with quote
Easy way to do this is to ask HMS if they allow host headers - then get them to set up any header coming into intranet.mdff.org to go into the correct directory.

Just curious though - why is an intranet site going to be on the internet - doesn't that defeat the whole purpose of an intranet vs. internet?
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1031
Location: Felton, Delaware
Reply with quote
They don't allow host headers... they will point the third level domains to the IP address, but from there it's up to you. This would be easy enough via ASP tho... lemme work on it just a bit...
apexonelove


Joined: 30 Mar 2005
Posts: 7
Location: Utah
Reply with quote
thanks guys...
Code:
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1031
Location: Felton, Delaware
Reply with quote
Okay... this is what I've come up with... this is off the top of my head, so no guarantee... but see where you can get with this...

Code:
<%
   
   dim yourDomainName, removeTheseStrings, invalidChars, requestedURL, workingURL, invalidCharsArray, removeStringsArray
   
   'Put your domain name here...  but only the FQDN...  no www
   'or anything...  just the domain name itself.
   yourDomainName = "joshandbrandi.com"
   
   'These are strings, separated by spaces, that will be
   'removed from the URL in order to determine which folder
   'the requestor should be redirected to.
   removeTheseStrings = "http:// https:// www."
   
   'These are just some last minute invalid characters
   'that could be in the requested URL *AFTER* the
   'processing of this script is finished.  Again, delimeted
   'by spaces >> " "
   invalidChars = "/ \ , . ! @ # $ % ^ & * ( ) _ + - = ` ~ { } [ ] ; : ' "" < > ?"
   
   'You probably don't need to change anything from this
   'point down, but hey...  in the end if you do, then
   'you do ;)
   requestedURL = Request.ServerVariables("URL")
   workingURL = requestedURL
   
   invalidCharsArray = Split(invalidChars," ")
   removeStringsArray = Split(removeTheseStrings," ")
   
   For i=LBound(removeStringsArray) To UBound(removeStringsArray)
      workingURL = workingURL.Replace(removeStringsArray(i),"")
   Next
   
   workingURL = workingURL.Replace(yourDomainName,"")
   
   If Len(workingURL) > 0 Then
      For i=LBound(invalidCharsArray) To UBound(invalidCharsArray)
         workingURL = workingURL.Replace(invalidCharsArray(i),"")
      Next
      If Len(workingURL) > 0 AND workingURL <> " " Then
         'Everything should be hunky dory...  so redirect to the requested folder...
         Response.Redirect(requestedURL & "/" & workingURL)
      Else
         'This says it all...
         Response.Write "Something's wonky with this script...  :?"
      End If
   Else
      'Well...  you figure it out.
      Response.Redirect(requestedURL)
   End If
   
%>
jamie
HostMySite Sales Rep
HostMySite Sales Rep

Joined: 19 Mar 2004
Posts: 770
Location: Newark, De
Reply with quote
Another client of ours is using something like this:

<% host = lcase(Request.ServerVariables("HTTP_HOST")) %>
<% If host="www.domain.com" Then Response.redirect("domainfolder1/") %>
<% If host="www.domain2.com" Then Response.redirect("domainfolder2/") %>

That seems really simple - would that work?
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1031
Location: Felton, Delaware
Reply with quote
that's just more manual... mine is more dynamic. The file wouldn't have to be updated when they added a new subfolder/web. Either will work just fine though... you are correct.
I have same problem - so what was the solution?
Suzanne Kirkland


Joined: 08 Jan 2006
Posts: 4
Location: West Chester, Pa.
Reply with quote
I have recently switched to HMS from 1&1.com and ran into the same problem - I have many domain names sharing one IP address and need to direct visitors to the right files based on the incoming url. I have been reading up on asp to figure out how to do this. I would greatly appreciate not re-inventing the wheel and would love to copy your solution, to include the file structure (i.e. where you placed the asp file, and how you organized the files for each domain). thanks!!!
ASP Redirect Help Needed Massiva
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic