<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
require_once("Kiss.php");
$kiss=new Kiss("db1","/ss/");//数据库路径
$posts=$kiss->getPostsByTime(20000);
foreach($posts as $post)
echo "
<url>
<loc>https://steelsheetstock.com/ss/{$post["rowid"]}.html"."</loc>
</url>";
require_once("Kiss.php");
$kiss=new Kiss("db2","/ssp/");//数据库路径
$posts=$kiss->getPostsByTime(20000);
foreach($posts as $post)
echo "
<url>
<loc>https://steelsheetstock.com/ssp/{$post["rowid"]}.html"."</loc>
</url>";
echo "</urlset>";
?>
配合伪静态.htaccess使用
#Kiss for apache兼容用。无需任何修改。
RewriteEngine On
RewriteRule ^a\.xml$ a.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /list.php [L]
Nginx伪静态语法
rewrite ^/sitemap\.xml$ /sitemap.php ##sitemap.php转sitemap.xml
rewrite ^/sitemap\.xml$ /sitemap.php;
if (!-f $request_filename){
set $rule_1 1$rule_1;
}
if (!-d $request_filename){
set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
rewrite /. /list.php last;
}
评论(0)