Reply to topic
Redirect Scripts
tmetz


Joined: 27 Oct 2004
Posts: 2
Reply with quote
One issue that comes up fairly frequently is people wanting to point multiple domain names at a hosting space and have them redirected to subdirectories (our policy is that we will point additional domains at the root directory for you, but you've got to do the rest!). This requires a redirect script, and people often ask if we know of one. I thought I'd maybe start a thread with scripts in various languages.

To start us off, here is a link to one in ASP:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6125&lngWId=4

And PHP:
http://www.zend.com/tips/tips.php?id=67&single=1

Anyone else?
Just what I have been looking for...
Suzanne Kirkland


Joined: 08 Jan 2006
Posts: 4
Location: West Chester, Pa.
Reply with quote
I have my websites here at host my site and I have been combing the internet for this very thing for the past 2 weeks. I was elated to find this thread right in my own backyard Smile . However, I cannot get the asp version to work for me. Crying or Very sad It always falls through to the "default site" which in my case is a response.write "site cannot be found". I only changed the placeholder site names to my domain names... any ideas?

<%@ Language=VBScript %>
<% response.buffer = True %>
<%
'Set up the redirect variables
Dim strURL 'This is the URL the user typed into the browser
Dim strSiteName 'This is the domain name
Dim intEPos 'This is the position of the remaining dot

strURL = Request.servervariables("HTTP_HOST")

intURLLen = len(strURL)
if inStr(1, UCase(strURL), "WWW") > 0 Then
strURL = Right(strURL, (intURLLen - 4))
End if

intEPos = inStr(1, strURL, ".")

strSiteName = UCase(Mid(strURL, 1, (intEPos - 1)))


Select Case strSiteName
Case "obhenterprises.com"
Response.redirect "http://www.obhenterprises.com/f1/index.htm"
Case "Troop96.net"
Response.redirect "http://www.troop96.net/f2/index.htm"
Case Else
Response.write "Site cannot be found"
End Select
%>
Check your CASE case
eflamm


Joined: 23 Jan 2006
Posts: 2
Reply with quote
Suzanne,

I think the problem is that you're upper-casing the strSiteName (UCase(strURL)), then testing it against mixed-case literals (Case "obhenterprises.com" ) - try making your text strings Upper Case as well ("OBHENTERPRISES.COM") and see if it works.

Eric
Suzanne Kirkland


Joined: 08 Jan 2006
Posts: 4
Location: West Chester, Pa.
Reply with quote
Thanks for responding. I am learning asp and VB script for the sole purpose of doing this redirect script so I am not too familiar with the languages as yet. For the benefit of other 'newbies' who are also trying to do this, I discovered that not only does the code change the string to upper case, but it also strips off the preceding "www." and trailing ".com". It is important to test only for the main portion of your domain name in the Select Case test string - e.g., Case "DOMAIN".
mgibbons


Joined: 28 Mar 2005
Posts: 4
Location: Bear, Delaware
Reply with quote
Here is the asp code for redirecting to a folder. You can use it by itself on the index page with the else statement, or remove the else statement and incorporate it into an existing index page. Regardless, this code will obviously only work on a page with the .asp extension:

<%

if (Request.ServerVariables("server_name") = "mike-gibbons.com") or (Request.ServerVariables("server_name") = "www.mike-gibbons.com") Then Response.Redirect ("/MikeGibbons/index.html") else ("/index.html") end if

%>

I use this on mgibbons.com, which is just a bogus site for showing customers stuff like this.
rora


Joined: 18 Jun 2006
Posts: 4
Reply with quote
Use server side settings.
Redirect script in PHP
tofuninja


Joined: 30 Dec 2006
Posts: 1
Location: DC
Reply with quote
I just tested this one out, and it works nicely for me:

http://forum.joomla.org/index.php?topic=24206.msg142493

I don't know if copying/pasting from their site is allowed, but the post with the code in it was made by CubaLibre.
Redirect Scripts
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