C

case php站点地图生成

Fsea 默认分类 2018-03-27
    <?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;
}
PREV
kiss-Class ‘SQLite3’ not found
NEXT
帝国cms建留言本的功能

评论(0)

发布评论