简体   繁体   English

Apache:无法将sitemap.xml重写为sitemap.php

[英]Apache: cannot rewrite sitemap.xml as sitemap.php

I have the following .htaccess file in the root (htdocs/johndoe) of my web document tree where index.php is found: 我的Web文档树的根目录(htdocs / johndoe)中有以下.htaccess文件,在其中找到index.php

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&menu1=$2&menu2=$3 [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?lang=$1&menu1=$2 [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?lang=$1 [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule sitemap.xml sitemap.php

Not sure what I am doing wrong, but when I access: 不知道我在做什么错,但是当我访问时:

http://localhost/johndoe/sitemap.xml

it just loads my index.php instead of calling sitemap.php . 它只是加载我的index.php而不是调用sitemap.php Where am I going wrong? 我要去哪里错了? Thanks. 谢谢。

Moving the rule: 移动规则:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule sitemap.xml sitemap.php

to the top of the .htaccess file just after the RewriteEngine on directive seemed to solve my problem. 指令RewriteEngine on之后的.htaccess文件顶部似乎可以解决我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM