0

I am working on a file help.php in directory help.I want to redirect user with the help of that help.php file to help.php/?step=2. For this I used code

header('location : help.php/?step=2');

But, instead of redirecting to help.php/?step=2 it is redirecting to help.php/help.php/?step=2. What is problem here?

1
  • remove the / and do header('location : help.php?step=2'); Commented Aug 19, 2019 at 17:22

1 Answer 1

1

Most likely the location path will be relative to your current path if you don't have a preceding slash. That is, a starting page /example.php and a location header of other.php will produce /example.php/other.php. In order to fix this, add the preceding slash in your location header:

header('location : /help.php?step=2');

Please look into the concept of relative vs. absolute paths for more information on this subject.

Sign up to request clarification or add additional context in comments.

2 Comments

talking about my url it is localhost/help/help.php and I want to redirect to localhost/help/help.php/?step=2. When I try your code it just redirect me to localhost/help.php/?step=2.
You never mentioned this in your original question. The solution is simple: you only need to update that line of code to header('location : /help/help.php?step=2');.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.