Re: How to ensure request coming from browser?
It's pretty tough to come up with a regex that will match all valid user agants. Plus most search engines, at least in some circumstances, spoof browser user-agents to protect against click-fraud.
If you're comfortable requiring JavaScript, I'd use JavaScript to inject a value that tells you the client's running JavaScript which makes certain it's a browser, e.g.,
ASP/VBScript example:
<%
Randomize
If IsEmpty(Session("injectedvalue")) Then
Session("injectedvalue") = CStr(Rnd())
%>
<html><head><script language="JavaScript">
window.location = "?iv=" + escape("<%= Session("injectedvalue") %>")
</script></head><body>
Innocuous text for spiders, etc.
</body></html>
<%
ElseIf Session("injectedvalue") <> Request.QueryString("iv") Then
Response.Redirect "wherever you want to send non-browsers"
End If
%>
Protected page here
This needs to be a little more complex if the page already has a uri-query on it.
|