Kirby 3 Bug with VirtualDocumentRoot

Hi guys,

there is a problem with Kirby 3 when using Apache’s VirtualDocumentRoot functionality (having multiple virtual hosts with only one configuration block in httpd.conf):

When trying to access the kirby pages, the path is not found. As soon as i change apache’s configuration to a regular virtualhost configuration everything works as expected).

With the very first version of Kirby 3 i tracked that problem down and changed one line of code in the area somewhere around the request uri is detected. Than kirby works with both regular virtual hosts and VirtualDocumentRoot configurations as well. Its just one simnple thing where the current request uri is not build properly… but I can’t find it again :frowning: and now i need to upgrade to the current version…

Therefore i need the help of the developing team to fix that kirby bug. It is very easy to reproduce:

Activate mod_vhost_alias and set up a configuration like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerAlias *.local

        # include the server name in the filenames used to satisfy requests
        VirtualDocumentRoot /home/vhosts/%0/

This serves virtual hosts from directories like:
and so on.

The problem is that kirby can not detected the request uri and will not serve any request. Instead it shows up an error message that something went wrong.

Any help is welcome.


I got it in kirby/src/Cms/App.php:

<         $requestUri  = '/' . $this->request()->url()->path();
>         $requestUri  = '/' . str_replace($_SERVER['HTTP_HOST'],"",$this->request()->url()->path());

In 3.2-rc1 this situation still exists, too. After fresh install 3.2-rc1 just keeps saying “Not found”.

As soon as you change that line, it starts working again under both conditions: Apache2 regular virtual hosts, and VirtualDocumentRoot configurations as well :+1:
Please consider taking this one over into the code base for the next release candidate.

Hopefully this can be updated for 3.2-rc2 @texnixe

I don’t know if this is a bug or not, please either create a bug issue in the kirby repo or a feature request in the ideas repo.


In your fix "Remove host from REQUEST_URI in Uri class (Fix #1830) "
there is something hardcoded:


Please check, whether this is intended (http:,
Sorry, I’m no profi in such coding, but I didn’t expect anything like that in the code.

Will be fixed in 3.2

That’s intended. It has been in there before. The parse_url method needs a full URL, not just a path, otherwise it will fail. Appending our domain is only there to make the parser work. The rest of the URL is detected further down.

1 Like

I also have the same problem, this is how my vhost conf look like:

UseCanonicalName Off

<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "/home/manu/var/www"

<VirtualHost *:80>
ServerName localhost
ServerAlias *.localhost
VirtualDocumentRoot "/home/manu/var/www/%1/web"

I’ve also tried the one from the arch wiki here.

With both configs I only get 404 errors on any subpage. I don’t know what is wrong with but it has defenitely to do with kirby itself and not my own config as it is working with other CMS quite nice.

My whole httpd.conf

@glumanda Have you tested if 3.2rc2 fixes this?

As already mentioned above, 3.2 is supposed to fix the issue.

@texnixe Yes, but it still won’t fix the issue for me. I don’t know what to do next, using php’s builtin server sucks.