• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

Sitemap.xml is Not Being Served Correctly

Bug Report
2
2
221
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • tribhuvanabhi
    tribhuvanabhi last edited by 25 Aug 2024, 15:50

    Issue: Sitemap.xml is Not Being Served Correctly on Hostinger with Laravel Setup
    Environment:

    Hosting Provider: Hostinger
    Project Type: Laravel (Bagisto)
    Website URL: devsamagri.com
    Directory Structure:
    public_html/ (Root directory)
    public_html/public/ (Laravel's public directory)
    Problem Description:

    I’m encountering an issue where my sitemap.xml is not being served correctly. Instead of being displayed as an XML file, it’s being treated as an HTML page, resulting in the error: "Your Sitemap appears to be an HTML page. Please use a supported sitemap format instead."

    What I’ve Tried:
    Generated the Sitemap:

    Created a sitemap.xml using xml-sitemaps.com.
    Uploaded the sitemap.xml file to both public_html/ and public_html/public/ directories.
    .htaccess Configuration:

    I have the following .htaccess setup in public_html:

    apache
    Copy code
    RewriteCond %{HTTP_HOST} ^devsamagri.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.devsamagri.com$
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L]

    Serve sitemap.xml as an XML file

    <FilesMatch "^sitemap.xml$">
    ForceType application/xml
    Header set Content-Type "application/xml"
    </FilesMatch>

    Serve sitemap_index.xml as an XML file (if applicable)

    <FilesMatch "^sitemap_index.xml$">
    ForceType application/xml
    Header set Content-Type "application/xml"
    </FilesMatch>

    Handle all other Laravel routes in the public folder

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ public/index.php [QSA,L]
    Outcome:

    The sitemap.xml file at https://devsamagri.com/sitemap.xml is served correctly and recognized by search engines.
    However, other URLs such as https://devsamagri.com/sitemap.php or any other dynamically generated sitemaps are not being served correctly—they return the home page or a text/html content type instead of application/xml.
    Request:
    I need assistance with:

    Ensuring that all sitemap URLs are served with the correct Content-Type: application/xml.
    Maintaining the existing Laravel routing and redirection rules.
    Any guidance or solutions to resolve this issue would be greatly appreciated. Thank you!

    1 Reply Last reply Reply Quote 0
    • Rishabh-Webkul
      Rishabh-Webkul last edited by 26 Aug 2024, 08:15

      Hello @tribhuvanabhi

      I think you are doing some customization because by default there is no page like this.

      https://devsamagri.com/sitemap.php

      And if the page didn't exist how it will go to homepage.

      The correct page is sitemap.xml

      Thanks & Regards

      1 Reply Last reply Reply Quote 0
      1 out of 2
      • First post
        1/2
        Last post