Hello all,
I have been following along with the PHP Novice To Ninja Book and using to build my own CMS.
I have implemented a simple Blog feature that lists all the blogs with links to the actual blogs: eg: https://www.room4studios.co.uk/blog/list contains links to https://www.room4studios.co.uk/blog/wholeblog?id=6 (those are live examples if you want to have a look)
So I need to somehow change it to https://www.room4studios.co.uk/blog/seo-friendly-url
Seemingly I want to link to the friendly url but behind the scenes actually serves the one with a parameters
I have been reading around about URL masking, mod-rewrites, canonical links and I’m confused about how to approach this, and would really appreciate if someone could take the time to explain a way forward.
Incase its useful my wholeblog function is :
public function wholeblog() {
$blog = $this->blogsTable->findById($_GET['id']);
$comments = $this->displayCommentsTable->findAllById($_GET['id']);
if (isset($_GET['commentid'])) {
$comment2edit = $this->commentsTable->findById($_GET['commentid']);
}
$title = $blog->blogHeading;
$metaDescription = $blog->metaDescription;
$canonical = 'blog/wholeblog?id=' . $blog->id;
$author = $this->authentication->getUser();
return ['template' => 'blogwhole.html.php',
'title' => $title,
'metaDescription' => $metaDescription,
'canonical' => $canonical,
'variables' => [
'blog' => $blog,
'comments' => $comments,
'comment2edit' => $comment2edit ?? '',
'user' => $author, //previously 'userId' => $author->id ?? null,
]
];
}