this is not working if this is coded in a file located more than 2 subdirectories..

header('location: admin.php');

i want to go back to the file to the main the root directory..

Recommended Answers

All 4 Replies

header('../location: admin.php');    // 1 folder up
header('../../location: admin.php'); // 2 folders up

Shuldn't it be:

header('location: ../admin.php'); // 1 folder up
header('location: ../../admin.php'); // 2 folders up

But HTTP 1.1 requires an absolute URI for the Location field so I am not sure if the above is OK to be used. Anyone knows more about that?

commented: Oops. Indeed... must be the heat ;) +14
commented: nice catch! +12

Never had any issues with it yet. Perhaps a server setting doing the translation to absolute?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.