Exclude sitemap.xml from htaccess.

huangapple go评论118阅读模式
英文:

Exclude sitemap.xml from htaccess

问题

当我尝试通过/sitemap.xml访问时,它只是加载主屏幕,URL没有变化,无论我在斜杠后面输入什么,它都会显示主页。

我认为sitemap.xml文件未找到,所以显示主页。如果我不使用htaccess,它可以正常工作。

这是htaccess的代码:

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

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] 

答案1

得分: 0

你必须在当前捕获它的重写规则中排除 sitemap.xml,例如通过在前面添加一个重写条件,测试不是 sitemap 文件名:

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

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] 

huangapple
  • 本文由 发表于 2023年7月18日 12:09:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76709477.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定