Hi there,
Goal:
user profile visible as:
http://mysite.com/username
So far visible as:
http://mysite.com/user.show?user=username
404 template:
<?php $username=$input->get->user;?>
<? $hello = $users->get($username);
echo $hello->name;
echo $hello->id;?>
I have added this to .htacces
RewriteRule ^[A-Za-z-]+/([A-Za-z0-9-]+)/?$ user.show?user=$1 [NC,L]
But it doesn't work.
It would be much better to not use 404 template.. Any idea how to get this working?
edit:
I've added page and template "show" with the above code.
I have added this code to header.inc
<?/**
* This hook modifies the default behavior of the Page::path function (and thereby Page::url)
*
* The primary purpose is to redefine blog posts to be accessed at a URL off the root level
* rather than under /posts/ (where they actually live).
*
*/
wire()->addHookBefore('Page::path', function($event) {
$page = $event->object;
if($page->template == 'show') {
$event->replace = true;
$event->return = "/$page->name/";
}
});?>
Seems like I'm missing something as it doesn't work for me.
And I can't access users path anyway as it's restricted, right?