Home WebServer PanelaaPanel Fixing the 404 Sitemap error on aaPanel using Nginx

Fixing the 404 Sitemap error on aaPanel using Nginx

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

Fixing the 404 Sitemap error on aaPanel using Nginx with 2 steps.

Introduction

The sitemap is a file containing information about a website, including all the website’s URLs, listed and arranged in the form of a hierarchical map (descending importance). Sitemaps help search engines crawl and index all your website content.

Currently, 2 popular Sitemap support Plugins are Rank Math and Yoast Seo. In this article, AZDIGI will guide you on fixing the 404 Sitemap error if encountered when using Rank Math and Yoast Seo on aaPanel running Nginx. Then when you create a Sitemap for your website, the default path of the sitemap will be in the form https://domain.com/sitemap_index.hmtl.

However, for some users using the Nginx server, when accessing the above link, they receive a 404 error with a specific error, as shown below. And to handle this problem, please continue to see this article.

Fixing the 404 Sitemap error on aaPanel using Nginx

Implementation Guide

With this error case, we will have 2 ways to fix it as follows:

Method 1: Fix on aaPanel interface

In this way, you just need to access the aaPanel interface, go to Website (1) >> Conf (2) (corresponding to the website to be configured) >> URL rewrite >> Copy the configuration content corresponding to the plugin you are using and paste in >> Save (5)

Fixing the 404 Sitemap error on aaPanel using Nginx
  • Yoast Seo
#Yoast SEO Sitemaps
location ~ ([^/]*)sitemap(.*).x(m|s)l$ {
  ## this rewrites sitemap.xml to /sitemap_index.xml
  rewrite ^/sitemap.xml$ /sitemap_index.xml permanent;
  ## this makes the XML sitemaps work
  rewrite ^/([a-z]+)?-?sitemap.xsl$ /index.php?yoast-sitemap-xsl=$1 last;
  rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
  rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
  ## The following lines are optional for the premium extensions
  ## News SEO
  rewrite ^/news-sitemap.xml$ /index.php?sitemap=wpseo_news last;
  ## Local SEO
  rewrite ^/locations.kml$ /index.php?sitemap=wpseo_local_kml last;
  rewrite ^/geo-sitemap.xml$ /index.php?sitemap=wpseo_local last;
  ## Video SEO
  rewrite ^/video-sitemap.xsl$ /index.php?yoast-sitemap-xsl=video last;
}
  • Rank Math
# START Nginx Rewrites for Rank Math Sitemaps
 rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
 rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
 # END Nginx Rewrites for Rank Math Sitemaps

Below is the configuration of Rank Math when I added it, with Yoast Seo, you also add the same. Once added, click Save.

Fixing the 404 Sitemap error on aaPanel using Nginx

Method 2: Add configuration via SSH

If you don’t have access to aaPanel or don’t like using the interface, you can add it directly via SSH. With aaPanel, to add configuration to use sitemap, we will need to open the file by path:

AZDIGI Tutorial
vi /www/server/panel/vhost/rewrite/sitewp.tk.conf;      ### Nhớ thay sitewp.tk bằng tên website của bạn
    
Fixing the 404 Sitemap error on aaPanel using Nginx

After adding the configuration is complete, now try to reaccess the Sitemap to check. As shown below, I have successfully handled the 404 Sitemap error and the Sitemap is already displayed normally.

Fixing the 404 Sitemap error on aaPanel using Nginx

So we have completed 2 methods to handle 404 Sitemap errors on aaPanel using Nginx. Hope this article is helpful to you, wish you success!

You can refer to other instructions at the link below:

If you need support, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign