XML - content-type

Hello,

I currently have a problem with the content-type of xml resources.

For example, if I put a GoogleSiteMap in a resource and change the resource type to XML, the header gets a content-type “text/xml”. But an “application/xml” is needed to create a valid sitemap.

Is there a way to influence the content-type?

Strangely, on the different sites with the same system (MODx Revo 2.8.3), the content-type of xml is sometimes “text/xml” and sometimes “application/xml”. What is the reason for this?


CMS: MODx 2.8.3
PHP: 7.3
MySQL: 5.6

you can change the mime type under top menu content / content type
default RSS is application/xml and XML is text/XML but you can change it there e.g. make a content type just for sitemaps

I usually dont worry about it as long as it validates on a 3rd party xml sitemap validator.

Just a note: there’s also Extras like GoogleSiteMap to help with creating sitemaps automatically if that is an option.

@servingpixels

Thanks for the information! I was not aware that RSS can also be used for XML.

However, the error seems to lie somewhere else. When I check my sitemap via a sitmap validator, I get a 404 error even though the page is reachable.

The header:

HTTP/1.1 200

244 ms

2a00:1158:300::68c

x-powered-by
PHP/7.3.23
expires
Thu, 19 Nov 1981 08:52:00 GMT
cache-control
no-store, no-cache, must-revalidate
pragma
no-cache
vary
Accept-Encoding
content-encoding
gzip
content-length
311
content-type
text/xml; charset=UTF-8
date
Thu, 06 Jan 2022 08:58:35 GMT
server
Apache

@vibedesign That’s exactly how I do it. The sitemap is validated via

[[!GoogleSiteMap? &context=`web` &containerTpl=`sitemapcont-tpl`]]

generated.

not quite sure I use GitHub - Sterc/seosuite: This repository contains the SEOSuite 2.x MODX extra.
and I get a valid sitemap on my site no 404 error and it validates. but googlessitemap should also work fine

header looks fine except for expire date which should nto make a difference

you sure that page is published and accessible to the web? happened to me before where I could view the page because I was logged in but it was unpublished so no one else can view it?

1 Like

I use GoogleSiteMap for other sites as well and so far I haven’t had any problems with it.

“you sure that page is published and accessible to the web?”

The resource is published, but there seems to be a problem with the accessibility. I’ll check all system settings first. It seems that the error does not affect XML directly.

As soon as I find the cause, I’ll get back to you.

Thanks for Support!

The error here was in the authorization of the resource. The resource sitemap.xml was assigned to a user group that did not have sufficient permissions…

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.