英文:
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]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论