Updated 8 February 2024
Sitemap in bagisto informs search engines which pages on a website should be crawled, and may help search engines discover and index those pages. While sitemaps can be a simple text file listing the URLs of all of the pages you’d like to have indexed, they can also be an XML document carrying more information.
With the help of this article, we will talk about creating a dynamic site.xml file for your Bagisto.
Add the File Name and File Path and click the Save Sitemap button.
Kindly make sure you created an XML file and mention its desired path as shown below.
Now you will able to see the new Sitemap as shown below.
By this, you can easily create a Sitemaps in Bagisto.
Thanks for reading this blog. Please comment below if you have any questions. Also, you can Hire Laravel Developers for your custom Laravel projects.
Hope it will be helpful for you or if you have any issues feel free to raise a ticket at our Support Portal
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
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
ForceType application/xml
Header set Content-Type “application/xml”
# Serve sitemap_index.xml as an XML file (if applicable)
ForceType application/xml
Header set Content-Type “application/xml”
# 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!