Plesk site preview and URLs / Panel

Hi there,

we are thinking about using Kirby as our new default CMS for clients, basically it works fine but usual procedure is to test the weeks before publishing without already having the final Domain www.y.de by using Plesk preview function which uses IP and URLs like http://xx.xx.xx.xx/plesk-site-preview/www.y.de/xx.xx.xx.xx .

What then happens is the generated site works fine but the panel permanently redirects to y.de - sometimes saving works, pagebuilder also sometimes, but most the time not: an ajax error alert pops or we get redirected or nothing happens :frowning:

Tanks for ideas and help!

I think i partly solved it :slight_smile:

Adding

c::set('url', 'http://xx.xx.xx.xx/plesk-site-preview/www.y.de/xx.xx.xx.xx');

to config.php did the trick.

But this brings new issues, publishing the site with this config and using the final domain will lead to problems, so i tried to use condition:

$preview_ip= "xx.xx.xx.xx";
if (substr($_SERVER['SCRIPT_URI'], 0, strlen($preview_ip)+7) == "http://{$preview_ip}" || substr($_SERVER['SCRIPT_URI'], 0, strlen($preview_ip)+8) == "https://{$preview_ip}") {
	c::set('url', "http://{$preview_ip}/plesk-site-preview/{$_SERVER['SERVER_NAME']}/{$preview_ip}");
}

but although
echo $_SERVER['SCRIPT_URI']
returns “http://xx.xx.xx.xx/plesk-…”

substr($_SERVER['SCRIPT_URI'], 0, 18)
returns “http://www.y.de:open_mouth:

How is that possible?