Hello all, Thought i would register here after looking through the forums and seeing alot of good advice. this is want i want to know. i know this is possible becuase i have seen it before a few years back but cant remember how to do it. To add extra security for a page on my website i want to build a javascript that redirects a user if they havnt come from a sertin page on my website. for example: download.html can only be accessed if its come from index.html so the user cannot put the web address directly in the address bar. can anyone help me with this Bobby
you should do this serverside via checking the http_referer value and not in js, if security is the reason for it.
JS is executed client-side, meaning that the client can choose to ignore or modify it. For this reason, it is not a safe way to secure your site. It would be better to look at the HTTP referer header server-side (e.g. PHP, ASP, Rails, etc.) that shows where the user has come from and redirect them if necessary.
Using asp.net something like: <% If Request.UrlReferrer.ToString.StartsWith("http://www.mypreferredreferringurl.com") Then Response.Redirect("Default.aspx") Else Response.Redirect("Default2.aspx") End If %> Code (markup):