944,008 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 3412
  • ASP RSS
Oct 10th, 2007
0

ASP redirect

Expand Post »
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
%>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dmah2007 is offline Offline
1 posts
since Oct 2007
Oct 12th, 2007
0

Re: ASP redirect

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"
Reputation Points: 53
Solved Threads: 13
Junior Poster
hopalongcassidy is offline Offline
148 posts
since Oct 2007
Oct 20th, 2007
0

Re: ASP redirect

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:
ASP Syntax (Toggle Plain Text)
  1. Dim strCurrentUrl = Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")
  2. 'If you need the querystring as well, use the line below
  3. 'Dim strCurrentUrl = Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME") & Request.ServerVariables("QUERY_STRING")
  4.  
  5. if InStr(1, strCurrentUrl, "payment", vbTextCompare) > 0 then
  6. response.redirect("/ylhl/payment/index.html")
  7. elseif InStr(1, strCurrentUrl, "willamettevalleycrane", vbTextCompare) > 0 then
  8. '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.
  9. response.redirect("/wvc/index.html")
  10. 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:
ASP Syntax (Toggle Plain Text)
  1. <%
  2. EnableSessionState=False
  3.  
  4. Dim host = Request.ServerVariables("HTTP_HOST")
  5. Dim url = Request.ServerVariables("SCRIPT_NAME")
  6. 'or if you prefer the below method. Both give same results.
  7. 'Dim url = Request.ServerVariables("URL")
  8.  
  9. if (host & url) = "willamettevalleycrane/payment" or (host & url)= "www.willamettevalleycrane.com/payment" then
  10. response.redirect("http://www.willamettevalleycrane.com/ylhl/payment/index.html")
  11. elseif host = "willamettevalleycrane.com" or host = "www.willamettevalleycrane.com" then
  12. response.redirect("http://www.willamettevalleycrane.com/wvc/index.html")
  13. end if
  14. %>
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.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Oct 20th, 2007
0

Re: ASP redirect

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.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Nov 26th, 2007
0

Re: ASP redirect

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:

ASP Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <meta http-equiv="Refresh"
  4. content="5;url=http://www.willamettevalleycrane.com/ylhl/payment/index.html">
  5. </head>
  6. <body>
  7. </body>
  8. </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!
Reputation Points: 10
Solved Threads: 3
Light Poster
CertGuard is offline Offline
48 posts
since Jul 2007
Nov 26th, 2007
0

Re: ASP redirect

Click to Expand / Collapse  Quote originally posted by CertGuard ...
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:

ASP Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <meta http-equiv="Refresh"
  4. content="5;url=http://www.willamettevalleycrane.com/ylhl/payment/index.html">
  5. </head>
  6. <body>
  7. </body>
  8. </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
Reputation Points: 53
Solved Threads: 13
Junior Poster
hopalongcassidy is offline Offline
148 posts
since Oct 2007
Nov 26th, 2007
0

Re: ASP redirect

Anytime
Reputation Points: 10
Solved Threads: 3
Light Poster
CertGuard is offline Offline
48 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Microsoft VBScript runtime error 800a0005
Next Thread in ASP Forum Timeline: Passing textarea, text values to popup





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC