I created a .html maintenance file and I want when someone goes to the site to redirect to the maintenance folder/index.html
my code: (default.asp at the root)
<%
If InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("abc.com") ) > 0 Then
Response.Redirect("/maintenance/")
ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("web.com") ) > 0 Then
Response.Redirect("/web/")
End If
%>
it works fine, if I go to abc.com but if I type in abc.com/blog it goes to the blog page. how do I prevent so it doesn't go to any sub folders.
Maybe using Request.ServerVariables["HTTP_HOST"]
can solve your problem.
Have you tried to look in the variable Request.ServerVariables("SERVER_NAME")
with a Response.Write
in order to see why the check on the string fails?
Are you using this "test > do" method instead of just taking the site down and creating a custom 404.html page because: (1) Your site receives calls via various domain names and you want some to work but not others; or (2) You just didn't think of using the 404 method?
Anyway, if you want to do it via code, then put this at the very top (before header-very important) of a page or even use this AS your index.asp or default.asp page:
<%
s_url = Request.ServerVariables("server_name")
s_url = lcase(s_url)
b_found = InStr(1,s_url, "abc.com",1)
if (b_found <> 0) then
response.redirect("/maintenance/")
end if
%>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.