What do I need to add to my .htaccess file so that I can get pretty URLs?
Currently, I have this two-line of code in my .htaccess file
Options +Multiviews
DefaultType applications/x-httpd-php
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteCond %{REQUEST_FILENAME}.php !-d
RewriteRule ^(.*)$ index.php?url=$1
RewriteRule ^single-blog/([0-9]+) single-blog?id=$1
Well, this code allows me stay in the page single-blog but, I am fetching data with the same id that I receive from URL.
My function to receive data from the id received from URL is like this:
function getSingleRow($table, $row_id){
global $conn;
$sql = "SELECT * FROM ".$table." WHERE id = ".$row_id;
$query = mysqli_query($conn, $sql);
if(mysqli_num_rows($query) <= 0){
return false;
} else {
$data = mysqli_fetch_assoc($query);
return $data;
}
}
So, when I used the single-blog/12 as URL the page throws multiple errors.