header using relative address and "../" does not work

2

How do I make a header for a page that is one level above, eg: I have the following tree of directories, I want to make a header of validarLogin.php for welcomePage.php? I tried to use a ../ to access the views folder and it did not work.

controller
--- validarCadastro.php
--- validarLogin.php
views
--- index.php
--- welcomePage.php

Redirect code:

$string = http_build_query($consulta);
$url = 'Location:'.'../views/welcomePage.php?'.$string;
header($url);
    
asked by anonymous 06.02.2015 / 16:27

1 answer

1

If you are using real paths (ie if you are not using Apache urls rewrite) something like the following code could solve:

$linkAtual = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$string = http_build_query($consulta);
$url = 'Location: '.$linkAtual.'/../views/welcomePage.php?'.$string;
header($url);

Location is usually quite rigid, notice that you did not put space between the : of the word Location and URL , it may also be what's been in the way.

If it still does not work, let me know a little bit more:  - You get some error, if so, then what error do you get?  - Do you use any platform or% pure%?  - Are you using PHP of sobre escrita not URLs ?

Let us know what worked for you.

    
25.02.2015 / 20:37