forked from barnabyalter/nyu-libraries-illiad-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherror.asp
48 lines (43 loc) · 1.37 KB
/
error.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<%@Language=VBScript CodePage = 65001%>
<%
Session.CodePage = 65001
Response.charset = "utf-8"
Session.LCID = 1033 'en-US
%>
<%
'setup variables
dim errorType, fileBase, absolutePath
'The error type 404, 403, 500 and 422 (in some occasions)
if not IsEmpty(Request.QueryString("error")) then
errorType = Request.QueryString("error")
end if
'Prepend this absolute path to links and images
'for when page is called from non-local server
absolutePath = "https://library.nyu.edu"
'The file base for the error page wrapper
If not IsEmpty(errorType) and errorType = 500 Then
fileBase = absolutePath & "/500-illiad.html"
ElseIf not IsEmpty(errorType) and errorType = 403 Then
fileBase = absolutePath & "/403.html"
Else
fileBase = absolutePath & Request.ServerVariables("script_name")
End If
'Setup http call to get file contents
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", fileBase, false
xmlhttp.send ""
'Print error if URL couldnt be found
if err.number <> 0 then
response.write "URL not found."
else
'Make links absolute for attributes: link, src, action, href
Dim regEx, printText
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.Pattern = "<head>"
printText = regEx.Replace(xmlhttp.responseText, "<head><base href=""" & absolutePath & """ />")
response.write printText
end if
set xmlhttp = nothing
%>