Redirect to index.php on multisite setup

i’m using multisite setup.
There are several redirects, for example in .htaccess to index.php… but on multisite setup, direct opening of index.php results in a 404.
i think this is because of some routing. maybe kirby thinks “index.php” is a folder inside content folder?

The redirect to index.php means that your are sent to the router. The index.php is usually not directly accessible.

what i wanted to say:
kirby links/redirects several times to index.php and this results in 404…
maybe this is solved, when it links to / instead of index.php

Any steps to reproduce this?

Please also provide information about your server setup, PHP and Kirby version.

i use this theme
since this theme is not free, i can’t provide it to you.

  • php 7.2.29 (dedicated docker image)
  • kirby v3.4.4
  • Plugins (i gues the most are not related… i just post them to be precise):
    • autoresize
    • bouncer
    • cachebuster
    • commentions
    • datamints_ldap
    • editor
    • editor-gallery-block
    • editor-info-block
    • editor-intro-block
    • editor-table-block
    • k3-image-clip
    • kirby3-autoid
    • kirby3-feed
    • kirby3-robots-txt
    • kirby3-video
    • kirby-builder
    • kirby-colors
    • kirby-sanitizer
    • lessphp
    • locator
    • retour-for-kirby
    • securedpages
    • similar
    • sitemapper


# Apache block users from browsing folders without a default document
<IfModule mod_autoindex.c>
  Options -Indexes

# Kirby .htaccess
# revision 2020-06-15

# rewrite rules
<IfModule mod_rewrite.c>

# enable awesome urls. i.e.:
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder;
# otherwise links or the entire site will break.
# If your homepage is,
# set the RewriteBase to:
# RewriteBase /mysite

# In some environments it's necessary to
# set the RewriteBase to:
# RewriteBase /

# Cachebuster plugin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.(\d+)\.(js|css)$ $1.$3 [L]

# block files and folders beginning with a dot, such as .git
# except for the .well-known folder, which is used for Let's Encrypt and security.txt
RewriteRule (^|/)\.(?!well-known\/) index.php [L]

# block all files in the content folder from being accessed directly
RewriteRule ^content/(.*) index.php [L]

# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]

# block direct access to Kirby and the Panel sources
RewriteRule ^kirby/(.*) index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]


# pass the Authorization header to PHP
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

# compress text file responses
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]



require 'kirby/bootstrap.php';

$sites = [
  '' => 'example1',
  '' => 'example2',

$host = Url::host();
$root = $sites[$host];
$url  = 'https://' . $host;

$kirby = new Kirby([
    'roots' => [
        'index'         => __DIR__,
        'blueprints'    => __DIR__ . '/site/theme/blueprints',
        'collections'   => __DIR__ . '/site/theme/collections',
        'controllers'   => __DIR__ . '/site/theme/controllers',
        'models'        => __DIR__ . '/site/theme/models',
        'snippets'      => __DIR__ . '/site/theme/snippets',
        'templates'     => __DIR__ . '/site/theme/templates',
        'site'          => __DIR__ . '/site',
        'content'       => $root . '/content',
        'media'         => $root . '/media',
        'assets'        => $root . '/assets',
        'config'        => $root . '/config'
    'urls' => [
      'media'  => $url . '/' . $root . '/media',
      'assets' => $url . '/' . $root . '/assets',

echo $kirby->render();

For one thing, your last rewrite rules are outside of the <mod_rewrite> block, secondly, I think order is important and these rules should probably be at the top after RewriteEngine on.

thx… i changed it… but this does not fix the original problem.

for example redirects to an results in a 404
(taken from log)

i think it’s about the rewrite rule for www. maybe this one needs a change? I’m sorry… i don’t know if this rule is the best solution for people entering

If this only happens when redirecting from non-www to www, then it’s probably an issue with your rule.

Do you have any other redirects set up, maybe in retour? Because normally, wp-login should end up in an error without a prior redirect.

Retour is installed, but not in use, because auf this:

i’m confused… the problem of redirection to /index.php existed several days… in several browsers (also private tabs/incognito mode, etc.)… maybe it was a strange caching problem… but i’m not able to reproduce the problem right now.

seems to be solved… but I’m not sure right now…