friendly URL checks and ajax

0

I have the following problem, I made a friendly URL, but it is giving "conflict" when I use ajax in my forms, when I click submit, it duplicates my site, my checks are like this

if(isset($_GET['url'])){

   $url=$_GET['url'];

   $sepURL=explode('/',$url);

}

$diretorio="paginas";

if(empty($sepURL)){

   include_once("$diretorio/home.php");

}elseif(isset($sepURL[0]) && $sepURL[0] == 'classificados' || isset($sepURL[0]) && $sepURL[0] == 'noticias'){

   include_once("$diretorio/class.php");

}elseif(isset($sepURL[0]) && $sepURL[0] == 'contato'){

   include_once("$diretorio/contato.php");

}

With this check, it is duplicating the site when I press some submit that uses ajax on the site, does anyone know how to solve it?

    
asked by anonymous 12.10.2018 / 23:46

1 answer

0

If the url parameter is not specified it will always fall into the home, have you thought to add a null condition? for if a url is specified in this field and it is not predefined, will you check if there is a file with that name? so you mount specific callbacks for your ajax routes ..

Just add something like this in the end

elseif(file_exists($diretorio.$sepURL[0])){

   include_once($diretorio.$sepURL[0]);

}
    
13.10.2018 / 02:29