Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
thinkingpixels
Topic Author
Posts: 17
Joined: 06 Jul 2016, 18:27

Missing "/" in sitemap.xml - gallery hosted in subfolder

15 Oct 2024, 07:40

I recently update my website thinkingpixels.com and along with it my photo gallery, which I have in a subdirectory "galerie", so the path to it is "thinkingpixels.com/galerie/" and the gallery itself works fine. However, I have used the X3 Sitemap Creator to generate a sitemap.xml for my gallery and all the URLs referenced in the XML look like this: "thinkingpixels.comgalerie/..." - there's a "/" missing after the top level domain.
How do I fix this?

Cheers,
André
 
User avatar
thinkingpixels
Topic Author
Posts: 17
Joined: 06 Jul 2016, 18:27

Re: Missing "/" in sitemap.xml - gallery hosted in subfolder

15 Oct 2024, 09:56

Okay, looks like I fixed it through editing the create_image_sitemap.php file, changing this part...

Code
// define SITE_URL constant with http or https
function get_site_url() {
  $protocol = (isset($_SERVER['SERVER_PROTOCOL']) && stripos($_SERVER['SERVER_PROTOCOL'], 'https') === 0) ||
              (isset($_SERVER['REQUEST_SCHEME']) && stripos($_SERVER['REQUEST_SCHEME'], 'https') === 0) ||
              (isset($_SERVER['HTTPS']) && in_array($_SERVER['HTTPS'], ['on', 1])) ||
              (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ? 'https' : 'http';
  return $protocol . '://' . $_SERVER['HTTP_HOST'] . substr(dirname(__DIR__), strlen($_SERVER['DOCUMENT_ROOT']));
}
define('SITE_URL', get_site_url());
to this...

Code
// define SITE_URL constant with http or https
function get_site_url() {
  $protocol = (isset($_SERVER['SERVER_PROTOCOL']) && stripos($_SERVER['SERVER_PROTOCOL'], 'https') === 0) ||
              (isset($_SERVER['REQUEST_SCHEME']) && stripos($_SERVER['REQUEST_SCHEME'], 'https') === 0) ||
              (isset($_SERVER['HTTPS']) && in_array($_SERVER['HTTPS'], ['on', 1])) ||
              (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ? 'https' : 'http';
              $doc_root = rtrim(realpath($_SERVER['DOCUMENT_ROOT']), DIRECTORY_SEPARATOR);
              $dir = rtrim(realpath(dirname(__DIR__)), DIRECTORY_SEPARATOR);
              $path = '/' . ltrim(str_replace($doc_root, '', $dir), '/');
  return $protocol . '://' . $_SERVER['HTTP_HOST'] . $path;
}
define('SITE_URL', get_site_url());
This should work for both X3 gallery being installed in a subdirectory or in the root folder.
Might this be worth an update of your original code or was my issue just caused by silly me not finding any option to set the base url or something like that? :D If it's the latter, kindly let me know please. :)
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14469
Joined: 30 Sep 2006, 03:37

Re: Missing "/" in sitemap.xml - gallery hosted in subfolder

15 Oct 2024, 23:02

I just tested this in another X3 website, but I can't recreate the issue. See my test for X3 installed in subdir /en/:
https://www.catchinglight.no/en/sitemap/
https://www.catchinglight.no/en/sitemap.xml?1729047654 (created XML source)

This must be some other issue ...
 
User avatar
thinkingpixels
Topic Author
Posts: 17
Joined: 06 Jul 2016, 18:27

Re: Missing "/" in sitemap.xml - gallery hosted in subfolder

16 Oct 2024, 05:31

Hm, any idea what might cause this behaviour on my installation? Feel free to have a look at both https://thinkingpixels.com and https://thinkingpixels.com/galerie and let me know if there's any further information you want me to provide. I just want to make sure the sitemape URLs won't break again after future updates...
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14469
Joined: 30 Sep 2006, 03:37

Re: Missing "/" in sitemap.xml - gallery hosted in subfolder

16 Oct 2024, 22:20

When I look now, it works of course, because you have fixed it (even if it wasn't working). The only way I can find out why there is a missing slash, would be if you gave me FTP login so I can do some tests. Perhaps it has something to do with rules from the parent (Wordpress?) website, although I wouldn't really expect that to happen.