Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Header move up one directory?

Tags:

html

php

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.phphas 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.

like image 313
Carpetfizz Avatar asked Sep 18 '13 01:09

Carpetfizz


2 Answers

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");
like image 156
Jason McCreary Avatar answered Oct 06 '22 03:10

Jason McCreary


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");
like image 42
Andrew Berridge Avatar answered Oct 06 '22 04:10

Andrew Berridge