Pages as subdomains

Is it possible to have pages as subdomains. So .com/blog becomes blog.domain.com

Seen references for kirby v2 but not v3.

Any help massively appreciated.

You’d have to do a URL redirect to example.com/blog.

You could render the subpage directly by modifying the index.php:

<?php

require __DIR__ . '/kirby/bootstrap.php';

if ($_SERVER['SERVER_NAME'] === 'blog.domain.com') {
    echo (new Kirby)->render('blog');
} else {
    echo (new Kirby)->render();
}
7 Likes

Again learned something new, cool.

Brilliant thank you both for your help. :blush:

thank you for this! It’s working on my local server, however the live server doesn’t really understand the locations of my site’s assets anymore.
The generated file paths on local and live server are identical, except of course the base domain name, but all assets paths on the live server, i.e ‘2019.mylivewebsite.at/assets/style.css’, are just outputting the generated html of my ‘2019.php’ template…

I’ve tried fiddling around with the DNS settings of my hosting provider, but so far with no results. But to be honest my understanding of how subdomains or DNS works is kind of limited. Maybe could you explain what’s going on under the hood here, and if you have an idea how I can fix this problem? thanks a lot!