0

I have the following folder structure

/main/site/

the redirect script is in the following dir

/main/site/backend/

header('Location: ../register.php');

returns to /main/register.php/ when it should go to /main/site/register.php

It seems all ok in the code , since ../ should go back one dir,

someone know what is wrong?

Otávio Barreto
  • 1,536
  • 3
  • 16
  • 35

2 Answers2

1

It does not matter where your script resides - every Location instruction applies to what the outside looks like. If the script is requested thru https://www.example.com/main/site/backend/filename.php then it must redirect to ../../register.php or even better /main/register.php.

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
  • And "not work" means what? The HTTP logic is correct in there, but nobody knows if you end your PHP script properly or what the internet browser in question does (check https://stackoverflow.com/a/56790467/4299358 ) – AmigoJack Jul 17 '19 at 12:42
0

Try changing to this

header('Location: ./../register.php');

./ Forces PHP to look only in current directory

See this post

Moshe Gross
  • 1,206
  • 1
  • 7
  • 14