Print url leads to redirect 301


echo u();
echo site()->find('home')->url();



When I visit the url I come to:


It’s with an ending slash. When in my case use cURL it tries to get a page that is redirected.

That happends when Kirby is installed in a sub folder.

Shouldn’t it return a page url that is not redirect 301?

That comes from url::base(). I have created an issue on GitHub, but I haven’t tested if adding a trailing slash creates another issue. Maybe url::base() shouldn’t be changed but $kirby->urls()->index(). Or maybe even one level up: $site->url().

I don’t know where it should be added, but I can tell you how I solved my specific case.

$url = site()->find('home')->url() . '/';

As I said before it will turn home like this:


Then if I use another url like this one:

$url = site()->find('projects/project-a')->url() . '/';

It will output this:


By default it does not redirect ending slash to a none slash which, means I now can run cURL on both these urls. I don’t need to check if it’s a home url or if it’s installed in a sub folder environment.

How ever I would never append an ending slash on my urls in a template.

Maybe this will not help you at all, but anyway… Thanks! :slight_smile: