所以我设置了htaccess来获取文件名,例如/page.html并创建url /index.php?page_url=page,它适用于我的所有页面,但找不到sitemap.xml。
相反,它会加载一个没有内容的普通html页面,因为它返回index.php?page_url = sitemap而不是仅加载位于名为sitemap.xml的目录根目录中的站点地图文件
这是我的htaccess文件
RewriteEngine on
##### Security #####
## Keep people out of .inc files
<files *.inc.php>
order allow,deny
deny from all
</files>
<files *.inc.html>
order allow,deny
deny from all
</files>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
## Deny index views of directories with no index file ##
Options -Indexes
# Ensure php pages cannot be viewed with the exception of /index.php
RewriteRule ^index.php$ - [L]
# ensure all pages end with a slash if there's no .xxx terminator
RewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ /$1/%{QUERY_STRING [NC,R=301,L]
#fetch pages with no suffix and treat them as if they are html pages
RewriteRule ^([A-Za-z0-9|_|\-|\/]+)/$ /index.php?pageUrl=$1/&contentType=html&%{QUERY_STRING} [L]
#fetch pages with a suffix and treat them as if they are the approriate page type
RewriteRule ^([A-Za-z0-9|_|\-|\/]+).([html|rss|xml|php]+)$ /index.php?page_url=$1&contentType=$2&%{QUERY_STRING} [L]
.htaccess文件位于根目录下的sitemap.xml和robots.txt中,它还包含站点地图的完整网址,所以我不确定我在哪里出错了
答案 0 :(得分:0)
我从最后一行([A-Za-z0-9 | _ | - | /] +)中取出了xml。([html | rss | xml | php] +)$并且它有效现在很棒