search

Home  >  Q&A  >  body text

Exclude sitemap.xml from htaccess.

When I try to access using /sitemap.xml, it just loads the home screen, nothing changes in the URL, no matter what I put after the slash, it gives me the home page.

I think the sitemap.xml file is not found, so the homepage is displayed. If I don't use .htaccess file it works fine.

This is the code for the .htaccess file:

RewriteEngine On
RewriteRule ^([^/]+)$ index.php?page= [QSA,L]
RewriteRule ^/$ index.php [NC]
P粉814160988P粉814160988657 days ago609

reply all(1)I'll reply

  • P粉304704653

    P粉3047046532023-07-21 00:42:34

    You need to exclude it in the rewrite rules that currently capture sitemap.xml, for example by adding a rewrite condition in front to test if it is not a sitemap file name:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !/sitemap.xml
    RewriteRule ^([^/]+)$ index.php?page= [QSA,L]
    RewriteRule ^/$ index.php [NC]

    reply
    0
  • Cancelreply