3 months ago
Dear Railway Support Team,
I am experiencing an issue with the sitemap at https://blog.oautomatizador.click/sitemap.xml on my WordPress site hosted on Railway (Apache/2.4.62, Debian). The Google Search Console reports a "Could not fetch" error due to an incorrect Content-Type. I have attempted to fix this by modifying the .htaccess file, but the issue persists, and a recent change caused a 500 Internal Server Error.
Background:
Initially, the sitemap returned Content-Type: application/xml; charset=UTF-8, which Google Search Console rejected as it expects Content-Type: text/xml.
I added <FilesMatch "\.xml$"> Header set Content-Type "text/xml" </FilesMatch> to .htaccess, but it resulted in Content-Type: text/html; charset=iso-8859-1, indicating WordPress was processing the sitemap as an HTML page.
Adding the rule caused a 500 Internal Server Error, likely because the mod_headers module is not enabled.
After removing or adjusting the rule, the sitemap reverted to its original behavior (Content-Type: application/xml; charset=UTF-8 or text/html; charset=iso-8859-1), but the Google Search Console error persists.
1 Replies
3 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 3 months ago
2 months ago
1. Check for Sitemap Plugins or WordPress Settings
Many SEO/sitemap plugins (like Yoast, Rank Math) generate sitemaps. Check their settings, as some offer an option to set the exact Content-Type.
Disable all sitemap-related plugins and re-enable just one to see if conflicts are causing the misconfiguration.
2. Manual .htaccess Adjustments
If your Railway image has mod_headers
enabled, this .htaccess rule is correct:
<FilesMatch "\.xml$"> Header set Content-Type "text/xml; charset=UTF-8" </FilesMatch>
But if mod_headers is missing, this will break your site. To check if it’s enabled:
Look for
LoadModule headers_module modules/mod_headers.so
in the main Apache config, or contact Railway support for confirmation.
3. Use PHP to Set Headers
If .htaccess is unreliable, set headers directly in your theme or a custom plugin:
add_action( 'template_redirect', function() { if ( strpos( $_SERVER['REQUEST_URI'], 'sitemap.xml' ) !== false ) { header( 'Content-Type: text/xml; charset=UTF-8' ); } });
Add this to your theme functions.php
or as a must-use plugin. This ensures the correct header whenever the sitemap is accessed.
4. Test with Google
After changes, clear any CDN and browser caches.
Fetch your sitemap via Google Search Console and inspect the HTTP headers (using browser dev tools or curl).
The returned header should be:
Content-Type: text/xml; charset=UTF-8
OR
Content-Type: application/xml; charset=UTF-8
(Google accepts both, but prefers
text/xml
)
5. If the Server Returns 500 Internal Error
Review your .htaccess for any misconfigurations or unsupported directives.
Simplify your .htaccess gradually to identify which directive causes the problem.