.htacess redirects to wrong url

0

I had deployed the friendly url in a project to test, hence I decided to deploy in the CBT, but something is happening that I can not detect what it is. When I load the site in / it opens sign-in.php good, the business is when it redirects, the form has in verificaLogin action, however it loads in the url all the way along with the extension. And in this verificalogin.php if it goes wrong, it should go back to sign-in.php , and back, but it loads in url index.php , which I did not want. And if it works, it should go to pag_Contratos , this page is in view , however it is loading /model/pag_Contratos , and should only load pag_Contratos and with the right path. And if I type a wrong url, it goes to the 404 error page, and when I click on return to the main page, it goes to home load, and I put it to load sign-in . Like I said, I used this from another project, does it have something to do with it? Even changing the links?

Codes:

.htaccess (it's in root)

 RewriteEngine on
 RewriteCond %{SCRIPT_FILENAME} !-f
 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteRule ^(.*)$ index.php?url=$1

index.php (it's in root)

$home = 'view/sign-in';
$url = (isset($_GET['url'])) ? $_GET['url'] : $home;
if ($url != $home) {
    $dir = 'view/';
    $url = array_filter(explode('/', $url));
    $url = $dir. $url[0] . '.php'; 
}
// var_dump($url);
echo $url;
if (file_exists($url)) {
    include_once $url;
} else {
    include_once 'view/404.php';
}

sign-in.php (it's in view):

<form class="form-signin" method="post" action="verificaLogin">
<h1 class="h1-large">Login</h1>
<label for="inputEmail" class="sr-only">Endereço de E-mail</label>
<input type="text" name="txtu" maxlength="50" class="form-control" placeholder="Nome de Usuário"/>
<br>
<label for="inputPassword" class="sr-only">Senha</label>
<input type="password" name="txts" class="form-control" placeholder="Senha">
<br>

<div class="checkbox mb-3">
    <label class="p-small">
        <input type="checkbox" value="remember-me"> Lembrar minha senha
    </label>
</div>

<br>
</form>

checkLogin.php (is in model):

require_once 'conexao.php';
require_once 'banco-login.php';
require_once 'banco-chamado.php';

if ($_POST) {
$user = $_POST['txtu'];
$senha = $_POST['txts'];
session_start();

if (efetuarLogin($conexao, $user, $senha)) {
    session_start();
    $_SESSION['nome'] = $user;
    $cpf = pegaCpfUsuarioLogado($conexao, $user);
    $_SESSION['tipoUsuario'] = pegaTipoUsuario($conexao, $cpf);
    mysqli_close($conexao);
    if ($_SESSION['tipoUsuario'] == 2) {
        $_SESSION['log'] = 'ativo';
        header("location: pag_contratosCli");
    } else {
        $_SESSION['log'] = 'ativoTecnico';
        header("location: pag_contratosTec");
    }
} else {
    echo '<script> var r = confirm("Senha ou usuário incorreto!")
                        if (r === true) {
                            window.location.assign("sign-in");                   
                        } else {
                            window.location.assign("sign-in");
                        }
                        </script>';
}
}

404.php (it's in view)

<html>
    <head>
        <title>404</title>
        <meta charset="utf-8">
    </head>
    <body>
        <h1>Página não encontrada</h1>
        <a href="sign-in">Retornar a Home</a>
    </body>
</html>      
    
asked by anonymous 04.08.2018 / 07:59

0 answers