解决SAE下Sitemap插件不能写入的问题
你可以暂时地蒙骗所有人, 也可以永久地蒙骗部分人, 但不可能永久地蒙骗所有人。——林肯
初次使用Wordpress For Sae会遇到很多问题,例如不能直接在store下载theme和plugin,原因是sae不可写。
最近想把小站SEO,而且是在sae下遇到了这个问题,于是下载一个 baidu-sitemap-generator 的插件 ,不过SAE不可写,所以就无法生成sitemap.xml,插件也有sae选项,不过直接把sitemap.xml生成在Storage,但不能每次更新或新建文章都不是最新的。
插件设置页面也有关于sae用户的提示,如果是用SAE平台,打开网站根目录下的config.yaml加入两行代码:
1 2 | - rewrite: if ( path ~ "sitemap.xml" ) goto "wp-content/plugins/baidu-sitemap-generator/SAE_xml.php" - rewrite: if ( path ~ "sitemap.html" ) goto "wp-content/plugins/baidu-sitemap-generator/SAE_html.php" |
然后在wp-content/plugins/baidu-sitemap-generator/下新建文件SAE_xml.php和SAE_html.php。
SAE_xml.php代码如下:
1 2 3 4 5 6 | <?php header("Content-Type:text/xml"); $f = new SaeFetchurl(); $data = $f->fetch("http://smwell-wordpress.stor.sinaapp.com/sitemap.xml"); echo $data; ?> |
SAE_html.php代码如下:
1 2 3 4 5 6 | <?php header("Content-Type:text/html"); $f = new SaeFetchurl(); $data = $f->fetch("http://smwell-wordpress.stor.sinaapp.com/sitemap.html"); echo $data; ?> |