getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

UUID permalinks cause infinite redirects in subfolder setups #6003

Open JerikoOne opened 11 months ago

JerikoOne commented 11 months ago

Description

When Kirby is installed in a subfolder https://domain.tld/subfolder, page links added through the writer field/text block are not added correctly, the subfolder is cut off from the link, e.g. https://domain.tld/@/page/UUID. If for testing purposes you manually add the subfolder to the created link e.g. https://domain.tld/subfolder/@/page/UUID and open it, the resolved link becomes https://domain.tld/subfolder/subfolder/and/so/on, so it seems the resolve method doesn't recognize the subfolder as base.

Expected behavior
The created link should include the subfolder in which Kirby is installed, e.g. https://domain.tld/subfolder/@/page/UUID. The resolved link should point to https://domain.tld/subfolder/and/so/on

To reproduce

  1. Install Kirby in a subfolder
  2. Add a writer field to a blueprint
  3. Create some text, add a link to another page in it.
  4. Click on the link in the frontend
  5. See error

Your setup

Tested with Kirby RC2 and RC4

Additional context
Field method ->permalinksToUrls() works as expected, also when Kirby is installed in a subfolder.

lukasbestle commented 11 months ago

Thanks for your issue report.

As I wrote on Discord, the fact that the subfolder is missing in the URL is intended. The writer field inserts permalinks like /@/page/UUID (without the domain) to be compatible with setups on different hosts (e.g. multi-domain multi-language or local development hosts). So it also doesn't include the subfolder. But if your site uses the <base href="<?= url() ?>"> element in the HTML <head>, the browser will route those links to the proper locations.

Infinite redirects are however indeed Kirby's responsibility and are considered a bug. I haven't tested it myself yet though.