Forum Moderators: open
Currently need to redirect a whole site to the root of a new site (sitewide to root). I only have FTP access to the server. Site is old asp site using some sort of cms.
I tried the below code and got an error message:
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "myNewSite.com"
%>
This is my global.asa file:
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
End Sub
Sub Application_OnEnd
'nothing needed here for this example
End Sub
Sub Session_OnStart
Application.lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.unlock
End Sub
Sub Session_OnEnd
Application.lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.unlock
End Sub
</SCRIPT>
Can anyone please, please post the modified code for a 301? Also, I'm new to developing, and not sure about line breaks in all the asp code snippets I see online.
Sub Application_OnStart
End Sub
Sub Application_OnEnd
'nothing needed here for this example
End Sub
Sub Session_OnStart
Application.lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.unlock
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "myNewSite.com"
End Sub
Sub Session_OnEnd
Application.lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.unlock
End Sub
</SCRIPT>
Sub Application_OnStart
End Sub
Sub Application_OnEnd
'nothing needed here for this example
End Sub
Sub Session_OnStart
Application.lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.unlock
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "myNewSite.com"
'Destroys the Session. So that future calls will retrigger this code.
Session.Abandon
'Sends buffered output immediately.
Response.Flush
'Stops processing the .asp file and returns the current result.
Response.End
End Sub
Sub Session_OnEnd
Application.lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.unlock
End Sub
</SCRIPT>
References
Response Object [msdn.microsoft.com]
Session Object [msdn.microsoft.com]