Akiraz2 Blog URL Rules error

I installed this blog extension - akiraz2 Blog on my yii2 app. It works perfectly and I can access the blog page on mysite.com/blog url.

I wanted to remove site from my urls for static pages created inside the SiteController.php so I added the code below to the rule manager:

'<alias:[\w\-]+>' => 'site/<alias>',

It was successful but the blog url no longer works. It brings page not found error. When I remove the code the blog url works again.

Any idea to resolve this?

Hi @ajaxthemestudios, welcome to the forum.

This is a fairly inclusive rule that can be applied to other routes than ‘site/something’. In fact, it seems that the routes for blog module get caught by this rule.

Would you please show us all the url rules including those for blog?

Thanks @softark
I eventually tried this code below and it worked for me:

        'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
		'enableStrictParsing' => false,
        'rules' => [
			'blog' => 'blog/<alias>',
			'<alias:[\w\-]+>' => 'site/<alias>',			
        ],
    ],

As you can see, I had just one rule before which is why I did not post everything. I am not an expert in this so I am not sure if my solution is the best or if there are better one with no negative effect later. I will welcome any contribution.

As you have noticed, the appearance order of the rules is very important. :+1:

I wonder if it’s OK or not, since I’m not familiar with akiraz2’s blog. But it looks strange to me, because <alias> parameter in the route doesn’t have the counterpart in the url pattern.

I actually tried this first:

'blog/<alias:[\w\-]+>' => 'blog/<alias>'

It did not work. It was a trial and error thing for me. But so far, its work well.
Thanks for your help.

Hi @softark. I just discover that mysite.com/blog is not working. What works with the rule is mysite.com/blog/. Notice the url that works has a slash at the end.

I also realize that the url is missing the category alias. For example, if an article is published in “news” category, the url should be mysite.com/blog/news/my-article-slug. For now it works as mysite.com/blog/my-article-slug

I think these issues show the rule is wrong. Any idea how to resolve this?