phpsitemapsitemap.xml

Exclude sitemap.xml from htaccess


When I try to access by using /sitemap.xml it just loads the homescreen with no change in URL, whatever I give next to slash it gives me the homepage.

I think sitemap.xml is not found so it shows the homepage. If I don't use htacess it works.

This the code of htaccess:

RewriteEngine On
RewriteRule ^([^/]+)$ index.php?page=$1 [QSA,L]
RewriteRule ^/$ index.php [NC] 

Solution

  • You have to exclude the sitemap.xml from the rewrite rule that currently catches it, for example by adding a rewrite condition in front testing not being the sitemap filename:

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