Simple routing system
Firstly, I would consider switching off error suppression, and add in Exception handling. You could in this example add in a condition to check if each file exists before including it, for instance:

if ($sp_link[4] == 'profile' &amp;&amp; @$sp_link[5] == '' &amp;&amp; file_exists('profile.php')) {
    include_once 'profile.php';
}


It looks like you're using the query only to return a page title, and only in one instance. Is this correct? If so, amend you query to only return the data that you want, rather than returning the whole dataset from any particular table, for instance, if you only want the title tuple, change it to this:

$sql ='SELECT `title` FROM `posts` WHERE `post_id`=? AND `post_name`=?';
$stmt=$pdo-&gt;prepare($sql);
$stmt-&gt;execute([$sp_link[5], $sp_link[6]]);
$post=$stmt-&gt;fetch(PDO::FETCH_ASSOC);


To improve this further, you could turn this block of PHP into a function or method. Here's how one might achieve this aim:

function simpleSelect($fields = '*', $table = 'posts', $postId = '', $postName = '', $stmt = null){
    if(is_array($fields)){
        $fields = implode(',', $fields);
    }
    $sql = "SELECT `{$fileds}` FROM `{$table}` WHERE `post_id`=? AND `post_name`=?";
    $stmt = $pdo-&gt;prepare($sql);
    $stmt-&gt;execute([$postId, $postName]);
    return $stmt-&gt;fetch(PDO::FETCH_ASSOC);
}


Now the top of your code starting from $sql ='SELECT * from posts WHERE post_id=? AND post_name=?'; and ending with $post=$stmt-&gt;fetch(); becomes this:

$post = simpleSelect('title', 'posts', $sp_link[5], $sp_link[6], $stmt);


If you need to select multiple fields from the posts table, then you could do this (imagining that you want title and name fields returned):

$post = simpleSelect(['title', 'name'], 'posts', $sp_link[5], $sp_link[6], $stmt);


Finally, consider moving to an object-orientated approach. Exception handling and OO programming will be covered elsewhere.