PDA

View Full Version : Conditional redirection for SSI in vbscript



code_sniper
November 11th, 2007, 07:18 AM
I am making a website using server side includes. I have a doubt.
I have 4 pages:
index.asp
head_ssi.asp
body_ssi.asp
foot_ssi.asp


head_ssi.asp, body_ssi.asp & foot_ssi.asp are server side includes of index.asp.

Now i want set it in such a way that if "head_ssi.asp" is tried to access to directly, it should be redirected to "index.asp"

simplistik
November 11th, 2007, 10:29 AM
one way to do it is, set a conditional at the top index.asp, or even better some universal config file that you include into the top of each file. so in index.asp you'd have something like


<%
dim key
key = "some special key"
%>

<!--#include file="head_ssi.asp"-->
<!--#include file="body_ssi.asp"-->
<!--#include file="foot_ssi.asp"-->

then at the very top of each of your includes put the redirect under a conditional


<%
If (key <> "yourkey") or (key = "") Then
Response.Redirect "/index.asp"
End If
%>


note i'm not an asp guy (php ftw :P) so this code may not be exact, i just used the same ideology i'd use in php and converted it into asp