How do I specify a file redirect to a file one level above the current file in PHP? Here is my schematic so far:
-landing.html
-ajax
-checkLogin.php
checklogin.php
has the following code in it:
header("location:dashboard.html");
This obviously doesn't work since landing.php
is one level above. How can I select a file one directory above? I already tried ..landing.php
, but seems like it will only take filenames.
You should really use absolute paths (at least relative to your document root).
Consider if you move checkLogin.php
a directory deeper…
Any of the follow won't have a problem.
header("Location: /landing.html");
// or
header("Location: http://www.example.com/landing.html");
The accepted answer will take you to the root of the domain, not 1 folder up as specified.
To go one folder up:
header("Location: ../landing.html");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With