Cannot relocate media folder

Hi there,

I was trying to relocate my content and media folder so that multiple development versions can have access to the same content/media.

What I tried to do was change the index.php in the dev folder to that:

<?php

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

$kirby = new Kirby([
    'roots' => [
        'index'   => __DIR__,
        'site'    => __DIR__ . '/site',
        'assets' => __DIR__ . '/assets',
        'content' =>  '/full/path/to/rootfolder/content',
        'media' => '/full/path/to/rootfolder/media'
    ]
]);

echo $kirby->render();

Works like a charm for the content folder. But all my images get 404ed. When I check the html output in the browser it still refers to the old media folder that doesn’t exist anymore, but

echo $kirby->root('media');

returns the correct folder.

Thank you for your help!

Have you make sure that your webserver can write into the new media folder?

Yes, I checked that! If I’m correct it shouldn’t even need the write permissions to just display the images that are already in the media folder, right?

I assume thats true. What I have learned from this forum is that it possibly might be a caching problem?

Another solution, which does not require much change in your index.php is the one I have outlined in this post together with this cookbook recipe. This way, your index.php needs only to look like this:

<?php
require 'kirby/bootstrap.php';

$kirby = new Kirby([
  'roots' => [
    'index'   => __DIR__,
  ],
]);

echo $kirby->render();

For the media folder, you also have to set the urls property, not only the roots.

1 Like