我想我找到了一個解決方案。有用。但是我不知道這是否是正確的方法。
在sitemap.php
// Header forming
header("Content-type: application/xml; charset=utf-8");
echo "<?xml version='1.0' encoding='UTF-8'?>" . "\n";
echo "<?xml-stylesheet type='text/xsl' href='https://{$url}/sitemap.xsl'?>" . "\n";
echo '<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"' . "\n";
echo ' xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"' . "\n";
echo ' xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' ."\n";
以下行不應該包含的HTTPS調用的外部網站。但它只能是HTTP(除了呼叫我的站點)
// Header forming
header("Content-type: application/xml; charset=utf-8");
echo "<?xml version='1.0' encoding='UTF-8'?>" . "\n";
echo "<?xml-stylesheet type='text/xsl' href='https://{$url}/sitemap.xsl'?>" . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . "\n";
echo ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n";
echo ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' ."\n";
XSL文件中標題的相似方法。 這裏下面的一個沒有工作:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="https://www.w3.org/TR/REC-html40"
xmlns:sitemap="https://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="https://www.w3.org/1999/xhtml">
這裏的工作之一,其中呼叫HTTPS是隻在標籤下面<html>
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="https://www.w3.org/1999/xhtml">
如果我再補充一點頭,的內容文件不可視化,但作爲文件下載。 與當前標題:標題(「Content-type:application/xml; charset = utf-8」);它作爲網頁管理 –