Blank page on /sitemap.xml when using Drupal in subfolder

Created on 8 August 2023, 11 months ago

Problem/Motivation

The sitemap.xsl link for the xml file gets built by using the base url and then pasting the route path behind it:

$scheme = \Drupal::request()->getScheme();
$context = $this->sitemap->getContext();
$base_url = $scheme . '://' . $url_settings['domains'][$context['language']];
$xls_url = Url::fromRoute('xmlsitemap.sitemap_xsl');
$xls_url = $base_url . '/' . $xls_url->getInternalPath();

This breaks websites that run in subfolders.

Steps to reproduce

Create a Drupal website that runs in a subfolder, and generate the sitemaps with styling enabled in the settings.

Proposed resolution

Let's build the .XSL file url the way Drupal intends it, by using the `Url::fromRoute()` method and adding the language in the options array.
I'll attach a patch for this.

I'm sorry if an issue for this already exists, I couldn't find one.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium RandalV

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024