User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 456,534 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,041 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1965 | Replies: 6
Reply
Join Date: Oct 2007
Posts: 1
Reputation: dmah2007 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dmah2007 dmah2007 is offline Offline
Newbie Poster

ASP redirect

  #1  
Oct 10th, 2007
HELP.....our web server requires we use an ASP page to redirect our 20 URLs to subwebs. This I can deal with. However, we want clients to be able to go directly to a page within a site by typing in www.WillametteValleyCrane.com/payment and get redirected to the page in the web. The ASP only directs the URL. When the "/payment" is added the redirect does not work.

Can we adjust the script to make it redirect? Thanks!

<%EnableSessionState=False

host = Request.ServerVariables("HTTP_HOST")

if host = "willamettevalleycrane.com" or host = "www.willamettevalleycrane.com" then
response.redirect("http://www.willamettevalleycrane.com/wvc/index.html")

if host = "willamettevalleycrane/payment" or host = "www.willamettevalleycrane.com/payment" then
response.redirect("http://www.willamettevalleycrane.com/ylhl/payment/index.html")

end if
%>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Posts: 145
Reputation: hopalongcassidy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 13
hopalongcassidy's Avatar
hopalongcassidy hopalongcassidy is offline Offline
Junior Poster

Re: ASP redirect

  #2  
Oct 12th, 2007
Are you sure you have a file named index.heml in your "payment" folder? The page your code redirects to is is "http://www.willamettevalleycrane.com/ylhl/payment/index.html"
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: ASP redirect

  #3  
Oct 20th, 2007
Instead of using the host method, try searching for a certain pattern in your url. Use the code below as it is modified from yours:
Dim strCurrentUrl = Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")
'If you need the querystring as well, use the line below
'Dim strCurrentUrl = Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")  & Request.ServerVariables("QUERY_STRING")

if InStr(1, strCurrentUrl, "payment", vbTextCompare) > 0 then
  response.redirect("/ylhl/payment/index.html")
elseif InStr(1, strCurrentUrl, "willamettevalleycrane", vbTextCompare) > 0 then
  'Unless you absolutely need `http://www.willamettevalleycrane.com` in your redirect, use the below line. This assumes that willamettevalleycrane.com is the current website you're on.
  response.redirect("/wvc/index.html")
else
Else, the reason why it is not direction is due to the following errors:
1. It will always detect willamettevalleycrane.com in your host even if it has payment along with it. If you want to keep your coding, switch the first if statement with the second so it detects the payment first.
2. HTTP_HOST will only return the current host as willamettevalleycrane.com. URL returns the remaining version like /payment.asp or what not.
3. Your second if statement is followed by an unclosed first (if ... then ... if) instead of (if ... then ... end if) or (if ... then ... elseif ... end if). Make the second if statement into elseif unless you close the first if statement with an end if. If you wish to keep your following code, then use this fixed version:
<%
EnableSessionState=False

Dim host = Request.ServerVariables("HTTP_HOST")
Dim url = Request.ServerVariables("SCRIPT_NAME")
'or if you prefer the below method. Both give same results.
'Dim url = Request.ServerVariables("URL")

if (host & url) = "willamettevalleycrane/payment" or (host & url)= "www.willamettevalleycrane.com/payment" then
  response.redirect("http://www.willamettevalleycrane.com/ylhl/payment/index.html")
elseif host = "willamettevalleycrane.com" or host = "www.willamettevalleycrane.com" then
  response.redirect("http://www.willamettevalleycrane.com/wvc/index.html")
end if
%>
I highly suggest using my first example. Less room for error especially in typo's int he address bar.
Last edited by SheSaidImaPregy : Oct 20th, 2007 at 6:38 pm.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: ASP redirect

  #4  
Oct 20th, 2007
oh, but if you're also just using these redirection urls for keeping records for you, your best bet is just to pass a variable to one page and then access it that way (like willamettevalleycrane.com/redirect.asp?company=wvc). This way you don't have to create a ton of folders and files. Otherwise.. carry on private.
Reply With Quote  
Join Date: Jul 2007
Posts: 48
Reputation: CertGuard is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
CertGuard's Avatar
CertGuard CertGuard is offline Offline
Light Poster

Re: ASP redirect

  #5  
Nov 26th, 2007
Although the suggestions above will work fine, there may be an easier way to accomplish that without all the complex coding.

All subfolders automatically resolve to "index.html" or "default.html" (depending on your server settings).

If you don't already have one, create a file (with the appropriate name as listed above) and add the following code to it:

<html>
<head>
<meta http-equiv="Refresh"
content="5;url=http://www.willamettevalleycrane.com/ylhl/payment/index.html">
</head>
<body>
</body>
</html>

the 5 that is diectly after content=" is the number of seconds before the user will be sent to the page.

HTH, Good Luck!
--
Robert Williams
CEO, Founder
CertGuard
Reply With Quote  
Join Date: Oct 2007
Posts: 145
Reputation: hopalongcassidy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 13
hopalongcassidy's Avatar
hopalongcassidy hopalongcassidy is offline Offline
Junior Poster

Re: ASP redirect

  #6  
Nov 26th, 2007
Originally Posted by CertGuard View Post
Although the suggestions above will work fine, there may be an easier way to accomplish that without all the complex coding.

All subfolders automatically resolve to "index.html" or "default.html" (depending on your server settings).

If you don't already have one, create a file (with the appropriate name as listed above) and add the following code to it:

<html>
<head>
<meta http-equiv="Refresh"
content="5;url=http://www.willamettevalleycrane.com/ylhl/payment/index.html">
</head>
<body>
</body>
</html>

the 5 that is diectly after content=" is the number of seconds before the user will be sent to the page.

HTH, Good Luck!


That's cool, thanks,

Hoppy
Reply With Quote  
Join Date: Jul 2007
Posts: 48
Reputation: CertGuard is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
CertGuard's Avatar
CertGuard CertGuard is offline Offline
Light Poster

Re: ASP redirect

  #7  
Nov 26th, 2007
Anytime
--
Robert Williams
CEO, Founder
CertGuard
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 4:43 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC