header(" Location:") Redirect from root directory

Asked

Viewed 1,807 times

-1

Hello! I’m a beginner in php, and I’m having trouble using the header(Location function).
Whenever I redirect a page, the path is from the directory of the current page!
Ex: Home/Forum/Images/ if I have a page inside the folder /Forum/ and use the header("Location: Localhost/Home/Pagina.php")to access a page that is in the directory /Home/, the link is "Localhost/Forum/Home/Pagina.php", and logically it does not find, is there any way I always set the search by directory from the root directory of the site? so that the searches are always made from /Home/ and not the page that has the Header()? function and the same doubt applies to the form action, when I create php forms!

Thank you just now!

.htaccess

<files phpsysinfo.ini>
  order deny,allow
  deny from all
</files>

2 answers

2


I don’t understand exactly what you’re doing, but do it like this:

header("Location: /Home/Pagina.php");

-2

was having a problem of the following type, my file was inside a directory and the page I wanted to redirect was in a repository before .

when I put it that way

header("Location:./app_agenda/new_cadastro.php?cadastro=1"); it added to the URL everything above adding to the current repository url

gave error object not found!!!!

I had to do it this way to make it work :)

header("Location:.. /.. /app_agenda/new_cadastro.php? cadastro=1");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.