Subfolder install - redirect to site url

Hi, this may be ridiculous, but I just can’t accomplish it, no matter what I try.

Kirby install is in the domain subfolder (the same is for the localhost subfolder).
How to create a redirect to Kirby site URL (subfolder URL)?


if ($kirby->user()) {

Whatever I try it redirects to the domain root.

I added the URL in config, but no changes.

I think you can use like that

if ($kirby->user()) {

Hi @ahmetbora, thank you very much for answering.

But, unfortunately, no, works the same as go('/');. Redirects to the domain root.
I tried Header::redirect() too, but it is the same.
Tried even go(page('home'), but again the same.

But the rest of the site works, ie all links to subpages and the Panel etc?

Yes, everything is normal, no issues, no errors.

How are you calling the url, like or do you point a subdomain to the subfolder?

I have the same install:

  1. Locally: localhost/kirby/projects/website-name
  2. Server:

I use multi-environment configs:

  1. config.localhost.php (‘url’ => ‘//localhost/kirby/projects/website-name’)
  2. (‘url’ => ‘’)

No subdomains.

Theoretically, this url shouldn’t work at all, because for the kirby installation at, dev/website-name should lead to the error page, because it is a page url that doesn’t exist. Don’t know why this setup works for you.

I’d recommend pointing a subdomain to that subfolder.

You are telling me that Kirby is not made to work in a subfolder at all?

Just for root domains or subdomains?

Hm, I didn’t know that.

I’m not sure, maybe it depends on the server configuration. But somehow, how would you differentiate between a subpage of the main domain and the project in the subfolder? In your case, it seems to work.

Have you set a rewrite base in your htaccess for the subfolder?

Well, I come from a WordPress background, so I assumed Kirby works no matter where I put it. Like a WordPress.

I develop locally using XAMPP, put Kirby projects in subfolders, and develop from there, for years now. Because of that, all my Kirby websites work wherever (domain, subdomain, subfolder, sub sub sub…folder), but recently I started noticing some things can’t work, like this issue in this thread.

Another thing where I had the issue, is with relative links, for sub-sub pages and deeper.
All the rest works without issues.

If Kirby autodetects where it is, and it has a config URL option, I don’t see why it shouldn’t support subfolders fully.

Should I create an issue in the GitHub repository for this? Or there is some good reason Kirby doesn’t want to support subfolders?

I don’t want to use htaccess for this, but it doesn’t work with htaccess changes either.

In XAMPP local setup, on a Kirby site installed on a subfolder, the use of go('/'); redirects outside of Kirby, did I understand correctly? For: usage of go('/') in http://localhost/test-kirbysite/blog/, redirects to http://localhost?

Hi, @ahmetbora, yes that’s right.
That also happens on any server I tested, when the Kirby install is in the subfolder.

Interestingly, for me, using go('/') redirects to Kirby homepage :thinking: (PHP 8.1, Windows 10, Kirby 3.8.3, XAMPP)

  • Which Kirby version do you test with, 3.8.3?
  • Same for starterkit/plainkit?
  • PHP version?

Hm, I will then create more tests.

That particular install is PHP 8.1, Windows 10, Kirby 3.7.3.
Didn’t test with starterkit/plainkit.

There were some changes and bugs related to URL and Enviroments in 3.7.x versions. You may be experiencing one of these. It should work fine on the latest stable Kirby version 3.8.3.

1 Like

Thank you, I will make some tests with the latest version. It would be great if subfolders work as in any other situation.