mboehler3 Posted September 21, 2011 Share Posted September 21, 2011 I am trying to 301 redirect a page, and I want to grab the Server Name using Request.ServerVariables. My 301 code looks like this: <%@ Language=VBScript %><%Response.Status="301 Moved Permanently"Response.AddHeader "Location", "https://<%= Request.ServerVariables("SERVER_NAME") %>/website.asp"%> But when I try to access the old page to see the redirect, I get this error in my browser: Microsoft VBScript compilation error '800a0401'Expected end of statement/surechoice/accounting-practice-management-insights.asp, line 4Response.AddHeader "Location", "https://<%= Request.ServerVariables("""SERVER_NAME""")-----------------------------------------------------------------------^ Is there a way to do this so that it will work (ie. read the quotations)? Link to comment Share on other sites More sharing options...
Ingolme Posted September 21, 2011 Share Posted September 21, 2011 That's because you're nesting ASP blocks. You can't have a block inside another block You basically have this: <% <%= Request.ServerVariables("SERVER_NAME") %> %> I don't know ASP, but you need to use a concatenator to append a variable to a string. I think in ASP the concatenator is &, but I'm not sure. Response.AddHeader "Location", "https://" & Request.ServerVariables("SERVER_NAME") & "/website.asp" Link to comment Share on other sites More sharing options...
mboehler3 Posted September 22, 2011 Author Share Posted September 22, 2011 That's because you're nesting ASP blocks. You can't have a block inside another block You basically have this:<% <%= Request.ServerVariables("SERVER_NAME") %> %> I don't know ASP, but you need to use a concatenator to append a variable to a string. I think in ASP the concatenator is &, but I'm not sure. Response.AddHeader "Location", "https://" & Request.ServerVariables("SERVER_NAME") & "/website.asp" This works, thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.