Hi i wonder if anyone could tell me if there would be a way to write a redirect into a .lc script?
essentially make it to where if a variable is not present it would redirect to another URL. an example of this (on its simplest terms) can be seen below:
Just out of curiosity, what is it you are doing? Are you sending people to a different website to keep people off of your server, or another page on your site?
I'm looking to do this (as an additional step) to redirect someone from accessing this URL without going through my app.
so i guess in some ways yeah (depending on the URL used in the app) to help keep them off. so if they get to it, and can see something that is intended to be viewed from the app it'll throw them to my homepage...
Something more simple could be to do the test, and if variable is not present, then just show some simple html website, but if the variable is present, then include some additional files where the rest of your lc code is :
<?lc
--test if this is an api call
put $_POST["variable"] into tVariable
if tVariable is not empty
then include "somefolder/otherfilewithstuff.lc"
else
--end test
?>
<html>
<head>
</head>
<body>
<header>
</header>
<div>
<h1>Welcome to my website</h1>
<p>
Hello, this is a website
</p>
</div>
<footer>
</footer>
</body>
</html>
Redirect should work, but it is vital to set and output the header before ANYTHING else emitted by the server, EVEN whitespace.
An extra blank line between ?> and another <?lc opening tag will break the redirection.
You could try an lc file that JUST outputs the redirect header to test, then go through your additional tests to add checks one by one.