Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Would anyone mind making a simple code change for me?

Status
Not open for further replies.

jmille34

Programmer
Sep 14, 2005
224
US
Hi, I could probably figure this out, but I don't speak asp, and this is important, so I don't want to screw it up. Plus, if this won't work for a 301 redirect or whatever, please let me know. Anyway, if anyone has a moment to use real syntax over the pseudocode in the second block, I'd really appreciate it.

I need this existing code modified:

Code:
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "offerfreedemo.asp"
%>

I need it to first check to see if a URL variable exists, such as ?source=blah, and if it does exist, then send a different location. Something like this:

Code:
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
if urlvariable("source") exists then
    Response.AddHeader "Location", "offerfreedemo.asp?source=$source"
else
    Response.AddHeader "Location", "offerfreedemo.asp"
endif
%>

The variable is always called "source" and sometimes it's there, and sometimes it's not. Any help/advice/code greatly appreciated.
 
try this:

Code:
Response.Status="301 Moved Permanently"
if [red]Len( Response.QueryString( "source") ) > 0[/red] then
    Response.AddHeader "Location", "offerfreedemo.asp?source=$source"
else
    Response.AddHeader "Location", "offerfreedemo.asp"
endif



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
hmm I dunno, I'm getting: "An error occurred on the server when processing the URL. Please contact the system administrator." I tried messing around with it, but I couldn't figure it out. Anyone know how to get a better error message?
 
That didn't do it.. I was using Firefox, and when I switched to IE, it showed more of a gui looking error, and when I unchecked the box, it showed the one from Firefox.. no line numbers or anything.
 
I figured it out in case anyone cares:

Code:
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
if Len(Request.QueryString("source")) > 0 then
	Response.AddHeader "Location", "offerfreedemo.asp?source=" + Request.QueryString("source")
else
	Response.AddHeader "Location", "offerfreedemo.asp"
end if
%>

just a syntax error, "endif" versus "end if"
and of course appending the actual contents of the variable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top